Skip to content

Commit

Permalink
render view one last time in case of render.error
Browse files Browse the repository at this point in the history
Try to render the view one last time in case a render.error is
triggered. If the view continues to throw exceptions, bail out and
just re-throw the exception.
  • Loading branch information
radnan committed Jan 9, 2013
1 parent 7c52c20 commit 89425f4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php
Expand Up @@ -63,6 +63,7 @@ public function __construct(View $view)
public function attach(EventManagerInterface $events) public function attach(EventManagerInterface $events)
{ {
$this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER, array($this, 'render'), -10000); $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER, array($this, 'render'), -10000);
$this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'render'), -10000);
} }


/** /**
Expand Down Expand Up @@ -130,11 +131,16 @@ public function render(MvcEvent $e)
try { try {
$view->render($viewModel); $view->render($viewModel);
} catch(\Exception $ex) { } catch(\Exception $ex) {
$application = $e->getApplication(); if ($e->getName() === MvcEvent::EVENT_RENDER_ERROR) {
$events = $application->getEventManager(); throw $ex;
$e->setError(Application::ERROR_EXCEPTION) }
->setParam('exception', $ex); else {
$events->trigger(MvcEvent::EVENT_RENDER_ERROR, $e); $application = $e->getApplication();
$events = $application->getEventManager();
$e->setError(Application::ERROR_EXCEPTION)
->setParam('exception', $ex);
$events->trigger(MvcEvent::EVENT_RENDER_ERROR, $e);
}
} }


return $response; return $response;
Expand Down

0 comments on commit 89425f4

Please sign in to comment.