404 code.

This commit is contained in:
Greyscale 2020-08-27 19:24:10 +02:00
parent 34a7f8e5a6
commit 2e68d4779f
2 changed files with 15 additions and 0 deletions

View file

@ -104,4 +104,9 @@ abstract class Controller
return $filter;
}
protected function pageNotFound() : Response {
return (new Response())
->withStatus(404);
}
}

View file

@ -12,6 +12,7 @@ abstract class HtmlController extends Controller
{
protected Twig $twig;
protected DebugBar $debugBar;
protected string $pageNotFoundTemplate = "404.html.twig";
public function __construct(
Twig $twig,
@ -57,4 +58,13 @@ abstract class HtmlController extends Controller
return $response;
}
protected function pageNotFound(): Response
{
$response = (parent::pageNotFound());
$response->withHeader('Content-Type', 'text/html');
$response->getBody()
->write($this->twig->fetch($this->pageNotFoundTemplate));
return $response;
}
}