mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 21:22:17 +00:00
[FEATURE] Moved loadedRoute to request so it can be easily overwritten
from middleware.
This commit is contained in:
@@ -15,7 +15,6 @@ class RouterBase {
|
|||||||
protected $processedRoutes;
|
protected $processedRoutes;
|
||||||
protected $controllerUrlMap;
|
protected $controllerUrlMap;
|
||||||
protected $backStack;
|
protected $backStack;
|
||||||
protected $loadedRoute;
|
|
||||||
protected $defaultNamespace;
|
protected $defaultNamespace;
|
||||||
protected $baseCsrfVerifier;
|
protected $baseCsrfVerifier;
|
||||||
|
|
||||||
@@ -144,9 +143,10 @@ class RouterBase {
|
|||||||
|
|
||||||
$routeNotAllowed = false;
|
$routeNotAllowed = false;
|
||||||
|
|
||||||
$this->loadedRoute = $route;
|
$this->request->loadedRoute = $route;
|
||||||
$route->loadMiddleware($this->request);
|
$route->loadMiddleware($this->request);
|
||||||
$route->renderRoute($this->request);
|
|
||||||
|
$this->request->loadedRoute->renderRoute($this->request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ class RouterBase {
|
|||||||
throw new RouterException('Route or method not allowed', 403);
|
throw new RouterException('Route or method not allowed', 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->loadedRoute) {
|
if(!$this->request->loadedRoute) {
|
||||||
throw new RouterException(sprintf('Route not found: %s', $this->request->getUri()), 404);
|
throw new RouterException(sprintf('Route not found: %s', $this->request->getUri()), 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,8 +178,8 @@ class RouterBase {
|
|||||||
* @return RouterEntry
|
* @return RouterEntry
|
||||||
*/
|
*/
|
||||||
public function getLoadedRoute() {
|
public function getLoadedRoute() {
|
||||||
if(!($this->loadedRoute instanceof RouterGroup)) {
|
if(!($this->request->loadedRoute instanceof RouterGroup)) {
|
||||||
return $this->loadedRoute;
|
return $this->request->loadedRoute;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -327,8 +327,8 @@ class RouterBase {
|
|||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($controller === null && $this->loadedRoute !== null) {
|
if($controller === null && $this->request->loadedRoute !== null) {
|
||||||
return $this->processUrl($this->loadedRoute, $this->loadedRoute->getMethod(), $parameters, $getParams);
|
return $this->processUrl($this->request->loadedRoute, $this->request->loadedRoute->getMethod(), $parameters, $getParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
$c = '';
|
$c = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user