mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Development
- Added new event when adding route. - Added `prependUrl` method to `LoadableRoute` class. - Added unit-test for add-route event. - Updated documentation to reflect new changes.
This commit is contained in:
@@ -151,18 +151,20 @@ class Router
|
||||
*/
|
||||
public function addRoute(IRoute $route): IRoute
|
||||
{
|
||||
$this->fireEvents(EventHandler::EVENT_ADD_ROUTE, [
|
||||
'route' => $route,
|
||||
]);
|
||||
|
||||
/*
|
||||
* If a route is currently being processed, that means that the route being added are rendered from the parent
|
||||
* routes callback, so we add them to the stack instead.
|
||||
*/
|
||||
if ($this->isProcessingRoute === true) {
|
||||
$this->routeStack[] = $route;
|
||||
|
||||
return $route;
|
||||
} else {
|
||||
$this->routes[] = $route;
|
||||
}
|
||||
|
||||
$this->routes[] = $route;
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user