Skip to content

Commit 6b8289c

Browse files
committed
Fixed issue with mixing named and unnamed routes in url generator
1 parent eeb327e commit 6b8289c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Router/UrlGenerator/GroupCountBasedDataGenerator.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function getData()
3434
$data = array();
3535
foreach ($routes[0] as $path => $methods) {
3636
$handler = reset($methods);
37-
$data[$handler['name']] = $path;
37+
if (is_array($handler) && isset($handler['name'])) {
38+
$data[$handler['name']] = $path;
39+
}
3840
}
3941

4042
foreach ($routes[1] as $group) {
@@ -48,16 +50,22 @@ public function getData()
4850
$part = $parts[$matchIndex - 1];
4951

5052
$method = reset($methods);
53+
if (!is_array($method[0]) || !isset($method[0]['name'])) {
54+
continue;
55+
}
5156
$parameters = $method[1];
52-
$path = rtrim($part, '()$~');
57+
58+
$path = $part;
5359

5460
foreach ($parameters as $parameter) {
55-
$path = $this->replaceOnce('([^/]+)', '{'.$parameter.'}', $path);
61+
$path = $this->replaceOnce('([^/]+)', '{' . $parameter . '}', $path);
5662
}
5763

64+
$path = rtrim($path, '()$~');
65+
5866
$data[$method[0]['name']] = array(
5967
'path' => $path,
60-
'params' => $parameters,
68+
'params' => $parameters
6169
);
6270
}
6371
}

0 commit comments

Comments
 (0)