Skip to content

Commit

Permalink
Dispatch afterDispatch event when exception is thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
biesbjerg committed Jul 13, 2016
1 parent 7763e5d commit bddff7d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/Cake/Error/ExceptionRenderer.php
Expand Up @@ -20,9 +20,12 @@
*/

App::uses('Sanitize', 'Utility');
App::uses('Dispatcher', 'Routing');
App::uses('Router', 'Routing');
App::uses('CakeResponse', 'Network');
App::uses('Controller', 'Controller');
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');
App::uses('CakeEvent', 'Event');

/**
* Exception Renderer.
Expand Down Expand Up @@ -287,7 +290,7 @@ public function pdoError(PDOException $error) {
protected function _outputMessage($template) {
try {
$this->controller->render($template);
$this->controller->afterFilter();
$this->_shutdown();
$this->controller->response->send();
} catch (MissingViewException $e) {
$attributes = $e->getAttributes();
Expand Down Expand Up @@ -327,4 +330,15 @@ protected function _outputMessageSafe($template) {
$this->controller->response->send();
}

protected function _shutdown() {
$this->controller->afterFilter();

$Dispatcher = new Dispatcher();
$afterDispatchEvent = new CakeEvent('Dispatcher.afterDispatch', $Dispatcher, array(
'request' => $this->controller->request,
'response' => $this->controller->response
));
$Dispatcher->getEventManager()->dispatch($afterDispatchEvent);
}

}

0 comments on commit bddff7d

Please sign in to comment.