[TASK] Made abstract ExceptionHandler class an interface.

- Updated documentation to reflect new changes.
This commit is contained in:
Simon Sessingø
2016-04-09 09:42:57 +02:00
parent 257875c6f9
commit 7234415e24
4 changed files with 17 additions and 14 deletions
+3
View File
@@ -55,6 +55,9 @@ This router is heavily inspired by the Laravel 5.* router, so anything you find
### Basic example
- ExceptionsHandlers must implement the `IExceptionHandler` interface.
- Middlewares must implement the `IMiddleware` interface.
```php
use Pecee\SimpleRouter\SimpleRouter;
-11
View File
@@ -1,11 +0,0 @@
<?php
namespace Pecee\Handler;
use Pecee\Http\Request;
use Pecee\SimpleRouter\RouterEntry;
abstract class ExceptionHandler {
abstract public function handleError(Request $request, RouterEntry $router = null, \Exception $error);
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Pecee\Handler;
use Pecee\Http\Request;
use Pecee\SimpleRouter\RouterEntry;
interface IExceptionHandler {
public function handleError(Request $request, RouterEntry $router = null, \Exception $error);
}
+3 -3
View File
@@ -2,7 +2,7 @@
namespace Pecee\SimpleRouter;
use Pecee\Exception\RouterException;
use Pecee\Handler\ExceptionHandler;
use Pecee\Handler\IExceptionHandler;
use Pecee\Http\Middleware\BaseCsrfVerifier;
use Pecee\Http\Request;
@@ -187,8 +187,8 @@ class RouterBase {
protected function handleException(\Exception $e) {
if($this->request->loadedRoute !== null && $this->request->loadedRoute->exceptionHandler !== null) {
$handler = new $this->request->loadedRoute->exceptionHandler();
if(!($handler instanceof ExceptionHandler)) {
throw new RouterException('Exception handler must be instanceof ExceptionHandler.');
if(!($handler instanceof IExceptionHandler)) {
throw new RouterException('Exception handler must be instanceof IExceptionHandler.');
}
$handler->handleError($this->request, $this->request->loadedRoute, $e);