File: /var/www/vhosts/creativefellows.nl/comtel.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 App\Domain\Breadcrumb\Data\BreadcrumbData;
use Psr\Http\Message\ResponseInterface;
use Psr\Container\ContainerInterface;
use Slim\Views\PhpRenderer;
use App\Domain\Cookie\CookieData;
final class DefaultErrorHandler
{
protected $container;
protected $responder;
protected $language;
protected $breadcrumbs;
protected $cookies;
public function __construct(
ContainerInterface $container,
PhpRenderer $responder,
BreadcrumbData $breadcrumbs,
LanguageData $language,
CookieData $cookies
) {
$this->container = $container;
$this->responder = $responder;
$this->language = $language;
$this->breadcrumbs = $breadcrumbs;
$this->cookies = $cookies;
}
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,
"breadcrumbs" => $this->breadcrumbs,
"cookies" => $this->cookies,
])->withStatus(404);
}
}