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:
Hannes
2022-01-02 14:42:43 +01:00
committed by GitHub
parent 749f252ffb
commit b5e42dbdfb

View File

@@ -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;
}
}
}