如何在 Zend Expressive 中渲染之前检查模板?这是我的行动:
class Section
{
private $container;
private $template;
public function __construct(ContainerInterface $container, Template\TemplateRendererInterface $template = null)
{
$this->container = $container;
$this->template = $template;
}
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
{
if (false === 'Exist or Not') {
return $next($request, $response->withStatus(404), 'Not found');
}
return new HtmlResponse($this->template->render('app::'.$request->getAttribute('path')));
}
}
我是ZE的新手。不知道如何做到这一点。