mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-15 18:23:26 +03: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:
@@ -35,6 +35,12 @@ class Router
|
||||
* @var bool
|
||||
*/
|
||||
protected $isProcessingRoute;
|
||||
|
||||
/**
|
||||
* Defines all data from current processing route.
|
||||
* @var array
|
||||
*/
|
||||
protected $currentProcessingRoute = [];
|
||||
|
||||
/**
|
||||
* All added routes
|
||||
@@ -371,6 +377,9 @@ class Router
|
||||
foreach ($this->processedRoutes as $key => $route) {
|
||||
|
||||
$this->debug('Matching route "%s"', get_class($route));
|
||||
|
||||
/* Add current processing route to constants */
|
||||
$this->currentProcessingRoute = $route;
|
||||
|
||||
/* If the route matches */
|
||||
if ($route->matchRoute($url, $this->request) === true) {
|
||||
@@ -429,6 +438,9 @@ class Router
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the current processing route after handle all possible routes */
|
||||
$this->currentProcessingRoute = [];
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->handleException($e);
|
||||
@@ -950,4 +962,4 @@ class Router
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user