File: /var/www/vhosts/creativefellows.nl/fvr.creativefellows.nl/src/Handler/DefaultErrorHandler.php
<?php
namespace App\Handler;
use App\Domain\Page\Data\PageData;
use App\Domain\Navigation\NavigationData;
use App\Domain\Language\LanguageData;
use Psr\Http\Message\ResponseInterface;
use Psr\Container\ContainerInterface;
use Slim\Views\PhpRenderer;
final class DefaultErrorHandler
{
protected $container;
protected $responder;
protected $language;
public function __construct(
ContainerInterface $container,
PhpRenderer $responder,
LanguageData $language
) {
$this->container = $container;
$this->responder = $responder;
$this->language = $language;
}
public function respond(ResponseInterface $response, PageData $page, $navigation) : ResponseInterface
{
$this->response = $response;
$this->page = $page;
$this->navigation = $navigation;
// get the labels
$localization = $this->language->localizedLanguageData()->setting("labels");
// set meta
$this->page->setMetaTitle($localization["404"]["title"]);
$this->page->setMetaDescription($localization["404"]["description"]);
// return
return $this->responder->render($this->response, "view.404.php", [
"navigation" => $this->navigation,
"page" => $this->page,
"localization" => $localization,
])->withStatus(404);
}
}