mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 21:22:17 +00:00
getRoute optimisations.
This commit is contained in:
@@ -113,10 +113,6 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
||||
$url = '//' . $this->getGroup()->getDomains()[0] . $url;
|
||||
}
|
||||
|
||||
if($parameters !== null) {
|
||||
|
||||
$params = array_merge($this->getParameters(), $parameters);
|
||||
|
||||
/* Contains parameters that aren't recognized and will be appended at the end of the url */
|
||||
$unknownParams = [];
|
||||
|
||||
@@ -128,15 +124,16 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
||||
|
||||
/* Replace any {parameter} in the url with the correct value */
|
||||
|
||||
$params = $this->getParameters();
|
||||
$max = count($params) - 1;
|
||||
$keys = array_keys($params);
|
||||
|
||||
for ($i = $max; $i >= 0; $i--) {
|
||||
$param = $keys[$i];
|
||||
$value = $value = isset($parameters[$param]) ? $parameters[$param] : $params[$param];
|
||||
$value = $value = ($parameters !== null && array_key_exists($param, $parameters)) ? $parameters[$param] : $params[$param];
|
||||
|
||||
/* If parameter is specifically set to null - use the original-defined value */
|
||||
if (array_key_exists($param, $parameters) && $parameters[$param] === null && isset($this->originalParameters[$param])) {
|
||||
if ($value === null && isset($this->originalParameters[$param])) {
|
||||
$value = $this->originalParameters[$param];
|
||||
}
|
||||
|
||||
@@ -150,7 +147,7 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
||||
|
||||
$url .= join('/', $unknownParams);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return rtrim($url, '/') . '/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user