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
+12
View File
@@ -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);
} }