Skip to content

Commit

Permalink
Added a fix for where getNamedRoute failed if declared within a Route…
Browse files Browse the repository at this point in the history
…Group
  • Loading branch information
Fredrik Sundblom committed May 20, 2021
1 parent edf5cf4 commit 5a343e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface

public function getNamedRoute(string $name): Route
{
if (!$this->routesPrepared) {
$this->collectGroupRoutes();
}

$this->buildNameIndex();

if (isset($this->namedRoutes[$name])) {
Expand Down Expand Up @@ -222,6 +226,13 @@ protected function buildOptionsRoutes(array $options): void
}
}

protected function collectGroupRoutes(): void
{
foreach ($this->groups as $key => $group) {
$group();
}
}

protected function processGroups(ServerRequestInterface $request): void
{
$activePath = $request->getUri()->getPath();
Expand Down

0 comments on commit 5a343e9

Please sign in to comment.