Skip to content
Browse files

prepareNotFoundViewModel listner - eventResult as ViewModel if set

  • Loading branch information...
1 parent 3a4cee6 commit 850a0605f29ee3b096a448af899e13ba05094acb @AndrejAndb AndrejAndb committed
Showing with 15 additions and 3 deletions.
  1. +15 −3 library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php
View
18 library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php
@@ -204,9 +204,21 @@ public function prepareNotFoundViewModel(MvcEvent $e)
// Only handle 404 responses
return;
}
-
- $model = new ViewModel();
- $model->setVariable('message', 'Page not found.');
+
+ 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

0 comments on commit 850a060

Please sign in to comment.
Something went wrong with that request. Please try again.