* @return void
*/
public function prepareNotFoundViewModel(MvcEvent $e)
{
$vars = $e->getResult();
if ($vars instanceof Response) {
// Already have a response as the result
return;
}
$response = $e->getResponse();
if ($response->getStatusCode() != 404) {
// Only handle 404 responses
return;
}
if (! $vars instanceof ViewModel) {
$model = new ViewModel();
if (is_string($vars)) {
$model->setVariable('message', $vars);
} else {
$model->setVariable('message', 'Page not found.');
}
} else {
$model = $vars;
if ($model->getVariable('message') === null) {
$model->setVariable('message', 'Page not found.');
}
}
$model->setTemplate($this->getNotFoundTemplate());
// If displaying reasons, inject the reason
$this->injectNotFoundReason($model);
// If displaying exceptions, inject
$this->injectException($model, $e);
// Inject controller if we're displaying either the reason or the exception
$this->injectController($model, $e);
$e->setResult($model);
}
/**
* Inject the not-found reason into the model
*
* If $displayNotFoundReason is enabled, checks to see if $reason is set,
* and, if so, injects it into the model. If not, it injects
* Application::ERROR_CONTROLLER_CANNOT_DISPATCH.
*
* @param ViewModel $model
* @return void
*/
protected function injectNotFoundReason(ViewModel $model)
{
if (! $this->displayNotFoundReason()) {
return;
}
// no route match, controller not found, or controller invalid
if ($this->reason) {
$model->setVariable('reason', $this->reason);
return;
}
// otherwise, must be a case of the controller not being able to
// dispatch itself.
$model->setVariable('reason', Application::ERROR_CONTROLLER_CANNOT_DISPATCH);
}
/**
* Inject the exception message into the model
*
* If $displayExceptions is enabled, and an exception is found in the
* event, inject it into the model.
*
* @param ViewModel $model
* @param MvcEvent $e
* @return void
*/
protected function injectException($model, $e)
{
if (! $this->displayExceptions()) {
return;
}
$model->setVariable('display_exceptions', true);
$exception = $e->getParam('exception', false);
// @TODO clean up once PHP 7 requirement is enforced
if (! $exception instanceof Exception && ! $exception instanceof Throwable) {
return;
}
$model->setVariable('exception', $exception);
}
/**
* Inject the controller and controller class into the model
*
* If either $displayExceptions or $displayNotFoundReason are enabled,
* injects the controllerClass from the MvcEvent. It checks to see if a
* controller is present in the MvcEvent, and, if not, grabs it from
* the route match if present; if a controller is found, it injects it into
* the model.
*
* @param ViewModel $model
* @param MvcEvent $e
* @return void
*/
protected function injectController($model, $e)
{
if (! $this->displayExceptions() && ! $this->displayNotFoundReason()) {
return;
}
$controller = $e->getController();
if (empty($controller)) {
$routeMatch = $e->getRouteMatch();
if (empty($routeMatch)) {
return;
}
$controller = $routeMatch->getParam('controller', false);
if (! $controller) {
return;
}
}
$controllerClass = $e->getControllerClass();
$model->setVariable('controller', $controller);
$model->setVariable('controller_class', $controllerClass);
}
}
* @return void
*/
public function prepareNotFoundViewModel(MvcEvent $e)
{
$vars = $e->getResult();
if ($vars instanceof Response) {
// Already have a response as the result
return;
}
$response = $e->getResponse();
if ($response->getStatusCode() != 404) {
// Only handle 404 responses
return;
}
if (! $vars instanceof ViewModel) {
$model = new ViewModel();
if (is_string($vars)) {
$model->setVariable('message', $vars);
} else {
$model->setVariable('message', 'Page not found.');
}
} else {
$model = $vars;
if ($model->getVariable('message') === null) {
$model->setVariable('message', 'Page not found.');
}
}
$model->setTemplate($this->getNotFoundTemplate());
// If displaying reasons, inject the reason
$this->injectNotFoundReason($model);
// If displaying exceptions, inject
$this->injectException($model, $e);
// Inject controller if we're displaying either the reason or the exception
$this->injectController($model, $e);
$e->setResult($model);
}
/**
* Inject the not-found reason into the model
*
* If $displayNotFoundReason is enabled, checks to see if $reason is set,
* and, if so, injects it into the model. If not, it injects
* Application::ERROR_CONTROLLER_CANNOT_DISPATCH.
*
* @param ViewModel $model
* @return void
*/
protected function injectNotFoundReason(ViewModel $model)
{
if (! $this->displayNotFoundReason()) {
return;
}
// no route match, controller not found, or controller invalid
if ($this->reason) {
$model->setVariable('reason', $this->reason);
return;
}
// otherwise, must be a case of the controller not being able to
// dispatch itself.
$model->setVariable('reason', Application::ERROR_CONTROLLER_CANNOT_DISPATCH);
}
/**
* Inject the exception message into the model
*
* If $displayExceptions is enabled, and an exception is found in the
* event, inject it into the model.
*
* @param ViewModel $model
* @param MvcEvent $e
* @return void
*/
protected function injectException($model, $e)
{
if (! $this->displayExceptions()) {
return;
}
$model->setVariable('display_exceptions', true);
$exception = $e->getParam('exception', false);
// @TODO clean up once PHP 7 requirement is enforced
if (! $exception instanceof Exception && ! $exception instanceof Throwable) {
return;
}
$model->setVariable('exception', $exception);
}
/**
* Inject the controller and controller class into the model
*
* If either $displayExceptions or $displayNotFoundReason are enabled,
* injects the controllerClass from the MvcEvent. It checks to see if a
* controller is present in the MvcEvent, and, if not, grabs it from
* the route match if present; if a controller is found, it injects it into
* the model.
*
* @param ViewModel $model
* @param MvcEvent $e
* @return void
*/
protected function injectController($model, $e)
{
if (! $this->displayExceptions() && ! $this->displayNotFoundReason()) {
return;
}
$controller = $e->getController();
if (empty($controller)) {
$routeMatch = $e->getRouteMatch();
if (empty($routeMatch)) {
return;
}
$controller = $routeMatch->getParam('controller', false);
if (! $controller) {
return;
}
}
$controllerClass = $e->getControllerClass();
$model->setVariable('controller', $controller);
$model->setVariable('controller_class', $controllerClass);
}
}
Fatal error: Uncaught Error: Class "Laminas\Mvc\View\Http\RouteNotFoundStrategy" not found in /home/metaseit/vendor/laminas/laminas-mvc/src/Service/HttpRouteNotFoundStrategyFactory.php:21
Stack trace:
#0 /home/metaseit/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(642): Laminas\Mvc\Service\HttpRouteNotFoundStrategyFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'HttpRouteNotFou...', NULL)
#1 /home/metaseit/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(264): Laminas\ServiceManager\ServiceManager->doCreate('HttpRouteNotFou...')
#2 /home/metaseit/vendor/laminas/laminas-mvc/src/View/Http/ViewManager.php(97): Laminas\ServiceManager\ServiceManager->get('HttpRouteNotFou...')
#3 /home/metaseit/vendor/laminas/laminas-eventmanager/src/EventManager.php(320): Laminas\Mvc\View\Http\ViewManager->onBootstrap(Object(Laminas\Mvc\MvcEvent))
#4 /home/metaseit/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent))
#5 /home/metaseit/vendor/laminas/laminas-mvc/src/Application.php(148): Laminas\EventManager\EventManager->triggerEvent(Object(Laminas\Mvc\MvcEvent))
#6 /home/metaseit/vendor/laminas/laminas-mvc/src/Application.php(260): Laminas\Mvc\Application->bootstrap(Array)
#7 /home/metaseit/public_html/popup-seite.ch/index.php(30): Laminas\Mvc\Application::init(Array)
#8 {main}
thrown in /home/metaseit/vendor/laminas/laminas-mvc/src/Service/HttpRouteNotFoundStrategyFactory.php on line 21