mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
[TASK] Made abstract ExceptionHandler class an interface.
- Updated documentation to reflect new changes.
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user