mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +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:
@@ -35,6 +35,12 @@ class Router
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $isProcessingRoute;
|
protected $isProcessingRoute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines all data from current processing route.
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $currentProcessingRoute = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All added routes
|
* All added routes
|
||||||
@@ -371,6 +377,9 @@ class Router
|
|||||||
foreach ($this->processedRoutes as $key => $route) {
|
foreach ($this->processedRoutes as $key => $route) {
|
||||||
|
|
||||||
$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) {
|
||||||
@@ -429,6 +438,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);
|
||||||
@@ -950,4 +962,4 @@ class Router
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user