Skip to content

Commit 3ffd7e5

Browse files
committed
refactor: add variable
To distinguish between from and routeKey.
1 parent 5c6e1d9 commit 3ffd7e5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

system/Router/RouteCollection.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,10 +1353,11 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
13531353
}
13541354
}
13551355

1356+
$routeKey = $from;
13561357
// Replace our regex pattern placeholders with the actual thing
13571358
// so that the Router doesn't need to know about any of this.
13581359
foreach ($this->placeholders as $tag => $pattern) {
1359-
$from = str_ireplace(':' . $tag, $pattern, $from);
1360+
$routeKey = str_ireplace(':' . $tag, $pattern, $routeKey);
13601361
}
13611362

13621363
// If is redirect, No processing
@@ -1371,7 +1372,7 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
13711372
$to = '\\' . ltrim($to, '\\');
13721373
}
13731374

1374-
$name = $options['as'] ?? $from;
1375+
$name = $options['as'] ?? $routeKey;
13751376

13761377
helper('array');
13771378

@@ -1380,16 +1381,16 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
13801381
// routes should always be the "source of truth".
13811382
// this works only because discovered routes are added just prior
13821383
// to attempting to route the request.
1383-
$fromExists = dot_array_search('*.route.' . $from, $this->routes[$verb] ?? []) !== null;
1384+
$fromExists = dot_array_search('*.route.' . $routeKey, $this->routes[$verb] ?? []) !== null;
13841385
if ((isset($this->routes[$verb][$name]) || $fromExists) && ! $overwrite) {
13851386
return;
13861387
}
13871388

13881389
$this->routes[$verb][$name] = [
1389-
'route' => [$from => $to],
1390+
'route' => [$routeKey => $to],
13901391
];
13911392

1392-
$this->routesOptions[$verb][$from] = $options;
1393+
$this->routesOptions[$verb][$routeKey] = $options;
13931394

13941395
// Is this a redirect?
13951396
if (isset($options['redirect']) && is_numeric($options['redirect'])) {

0 commit comments

Comments
 (0)