Permalink
Browse files

render view one last time in case of render.error

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...
1 parent 7c52c20 commit 89425f4abdf5f04e46d3aaa37a5716ac6fa07f27 @radnan committed Jan 9, 2013
Showing with 11 additions and 5 deletions.
  1. +11 −5 library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php
@@ -63,6 +63,7 @@ public function __construct(View $view)
public function attach(EventManagerInterface $events)
{
$this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER, array($this, 'render'), -10000);
+ $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'render'), -10000);
}
/**
@@ -130,11 +131,16 @@ public function render(MvcEvent $e)
try {
$view->render($viewModel);
} catch(\Exception $ex) {
- $application = $e->getApplication();
- $events = $application->getEventManager();
- $e->setError(Application::ERROR_EXCEPTION)
- ->setParam('exception', $ex);
- $events->trigger(MvcEvent::EVENT_RENDER_ERROR, $e);
+ if ($e->getName() === MvcEvent::EVENT_RENDER_ERROR) {
+ throw $ex;
+ }
+ else {
+ $application = $e->getApplication();
+ $events = $application->getEventManager();
+ $e->setError(Application::ERROR_EXCEPTION)
+ ->setParam('exception', $ex);
+ $events->trigger(MvcEvent::EVENT_RENDER_ERROR, $e);
+ }
}
return $response;

0 comments on commit 89425f4

Please sign in to comment.