Compare commits

...

3 Commits

Author SHA1 Message Date
Simon Sessingø 5a50190293 Merge pull request #100 from skipperbent/development
Development
2016-04-25 00:41:50 +02:00
Simon Sessingø f98e5ac59d - Optimized handleException method in RouterBase. 2016-04-23 10:52:51 +02:00
Simon Sessingø a2dbf4149b - Added route to ExceptionHandler so Middlewares can be loaded. 2016-04-23 10:50:56 +02:00
+8 -4
View File
@@ -89,9 +89,9 @@ class RouterBase {
$route->renderRoute($this->request);
$mergedSettings = array_merge($settings, $route->getMergeableSettings());
// Add exceptionhandler
// Add ExceptionHandler
if($route->matchRoute($this->request) && $route->getExceptionHandler() !== null) {
$this->exceptionHandlers[] = $route->getExceptionHandler();
$this->exceptionHandlers[] = $route;
}
}
@@ -178,8 +178,12 @@ class RouterBase {
protected function handleException(\Exception $e) {
foreach ($this->exceptionHandlers as $handler) {
$handler = new $handler($this->request);
/* @var $route RouterEntry */
foreach ($this->exceptionHandlers as $route) {
$route->loadMiddleware($this->request);
$handler = $route->getExceptionHandler();
$handler = new $handler();
if (!($handler instanceof IExceptionHandler)) {
throw new RouterException('Exception handler must implement the IExceptionHandler interface.');
}