0
Zend Expressiveでレンダリングする前にテンプレートをチェックする方法は?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に新しいです:ここに私の行動です。これを行う方法はありません。
あなたは怠惰でない場合、それは動作します:)二つのアクションは問題ではありません:) P.S.私はfile_exists()を使用します。 –