How to check template before rendering in Zend Expressive? Here is my action:
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')));
}
}
I am new in ZE. Have no Idea how to do this.