mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
@@ -116,6 +116,7 @@ class RouterBase {
|
|||||||
$routeNotAllowed = false;
|
$routeNotAllowed = false;
|
||||||
|
|
||||||
$this->loadedRoute = $routeMatch;
|
$this->loadedRoute = $routeMatch;
|
||||||
|
$routeMatch->loadMiddleware($this->request);
|
||||||
$routeMatch->renderRoute($this->request);
|
$routeMatch->renderRoute($this->request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,9 +179,9 @@ abstract class RouterEntry {
|
|||||||
public function getMergeableSettings() {
|
public function getMergeableSettings() {
|
||||||
$settings = $this->settings;
|
$settings = $this->settings;
|
||||||
|
|
||||||
if(isset($settings['middleware'])) {
|
/*if(isset($settings['middleware'])) {
|
||||||
unset($settings['middleware']);
|
unset($settings['middleware']);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(isset($settings['prefix'])) {
|
if(isset($settings['prefix'])) {
|
||||||
unset($settings['prefix']);
|
unset($settings['prefix']);
|
||||||
@@ -243,7 +243,7 @@ abstract class RouterEntry {
|
|||||||
return new $name();
|
return new $name();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadMiddleware(Request $request) {
|
public function loadMiddleware(Request $request) {
|
||||||
if($this->getMiddleware()) {
|
if($this->getMiddleware()) {
|
||||||
$middleware = $this->loadClass($this->getMiddleware());
|
$middleware = $this->loadClass($this->getMiddleware());
|
||||||
if (!($middleware instanceof Middleware)) {
|
if (!($middleware instanceof Middleware)) {
|
||||||
@@ -256,8 +256,6 @@ abstract class RouterEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function renderRoute(Request $request) {
|
public function renderRoute(Request $request) {
|
||||||
// Load middleware
|
|
||||||
$this->loadMiddleware($request);
|
|
||||||
|
|
||||||
if(is_object($this->getCallback()) && is_callable($this->getCallback())) {
|
if(is_object($this->getCallback()) && is_callable($this->getCallback())) {
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class RouterGroup extends RouterEntry {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function matchRoute(Request $request) {
|
public function renderRoute(Request $request) {
|
||||||
// Check if request method is allowed
|
// Check if request method is allowed
|
||||||
|
|
||||||
if(strtolower($request->getUri()) == strtolower($this->prefix) || stripos($request->getUri(), $this->prefix) === 0) {
|
if(strtolower($request->getUri()) == strtolower($this->prefix) || stripos($request->getUri(), $this->prefix) === 0) {
|
||||||
@@ -29,11 +29,17 @@ class RouterGroup extends RouterEntry {
|
|||||||
throw new RouterException('Method not allowed');
|
throw new RouterException('Method not allowed');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
$this->loadMiddleware($request);
|
||||||
|
|
||||||
|
return parent::renderRoute($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No match here, move on...
|
// No match here, move on...
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function matchRoute(Request $request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,9 +20,6 @@ class RouterResource extends RouterEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function renderRoute(Request $request) {
|
public function renderRoute(Request $request) {
|
||||||
// Load middleware
|
|
||||||
$this->loadMiddleware($request);
|
|
||||||
|
|
||||||
if(is_object($this->getCallback()) && is_callable($this->getCallback())) {
|
if(is_object($this->getCallback()) && is_callable($this->getCallback())) {
|
||||||
// When the callback is a function
|
// When the callback is a function
|
||||||
call_user_func_array($this->getCallback(), $this->getParameters());
|
call_user_func_array($this->getCallback(), $this->getParameters());
|
||||||
|
|||||||
Reference in New Issue
Block a user