[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:
Simon Sessingø
2015-11-01 08:23:46 +01:00
parent 637b998f02
commit 8557741083
6 changed files with 37 additions and 6 deletions
+3 -3
View File
@@ -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');
}