mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 06:32:20 +00:00
Make current processing rule accessible
Adds an constant with the data from the current processing rule to make it globally accessible, f.e. in middleware objects
This commit is contained in:
@@ -36,6 +36,12 @@ class Router
|
|||||||
*/
|
*/
|
||||||
protected $isProcessingRoute;
|
protected $isProcessingRoute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines all data from current processing route.
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $currentProcessingRoute = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All added routes
|
* All added routes
|
||||||
* @var array
|
* @var array
|
||||||
@@ -372,6 +378,9 @@ class Router
|
|||||||
|
|
||||||
$this->debug('Matching route "%s"', get_class($route));
|
$this->debug('Matching route "%s"', get_class($route));
|
||||||
|
|
||||||
|
/* Add current processing route to constants */
|
||||||
|
$this->currentProcessingRoute = $route;
|
||||||
|
|
||||||
/* If the route matches */
|
/* If the route matches */
|
||||||
if ($route->matchRoute($url, $this->request) === true) {
|
if ($route->matchRoute($url, $this->request) === true) {
|
||||||
|
|
||||||
@@ -430,6 +439,9 @@ class Router
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove the current processing route after handle all possible routes */
|
||||||
|
$this->currentProcessingRoute = [];
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->handleException($e);
|
$this->handleException($e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user