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初心者です。これを行う方法がわかりません。