mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
[FEATURE] Bugfixes and optimisations
- Changed Middleware to interface - as it's easier to inherit and use in other frameworks/projects. - RouterController now loads method based on request-method. - Changed references to old Middleware abstract class. - Middleware must now be instance of IMiddleware instead of Middleware class.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Pecee\SimpleRouter;
|
||||
|
||||
use Pecee\Http\Middleware\Middleware;
|
||||
use Pecee\Http\Middleware\IMiddleware;
|
||||
use Pecee\Http\Request;
|
||||
|
||||
abstract class RouterEntry {
|
||||
@@ -208,7 +208,7 @@ abstract class RouterEntry {
|
||||
public function setSettings($settings) {
|
||||
$this->settings = $settings;
|
||||
|
||||
if($settings['prefix']) {
|
||||
if(isset($settings['prefix'])) {
|
||||
$this->setPrefix($settings['prefix']);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ abstract class RouterEntry {
|
||||
public function loadMiddleware(Request $request) {
|
||||
if($this->getMiddleware()) {
|
||||
$middleware = $this->loadClass($this->getMiddleware());
|
||||
if (!($middleware instanceof Middleware)) {
|
||||
if (!($middleware instanceof IMiddleware)) {
|
||||
throw new RouterException($this->getMiddleware() . ' must be instance of Middleware');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user