mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Minor optimizations in Router
This commit is contained in:
parent
57997e770c
commit
2b353e90f8
1 changed files with 7 additions and 10 deletions
|
@ -788,7 +788,7 @@ class Router {
|
||||||
|
|
||||||
$prefixExists = (array_intersect_key($url, array_flip($self->__prefixes)));
|
$prefixExists = (array_intersect_key($url, array_flip($self->__prefixes)));
|
||||||
foreach ($self->__prefixes as $prefix) {
|
foreach ($self->__prefixes as $prefix) {
|
||||||
if (!isset($url[$prefix]) && !empty($params[$prefix]) && !$prefixExists) {
|
if (!empty($params[$prefix]) && !$prefixExists) {
|
||||||
$url[$prefix] = true;
|
$url[$prefix] = true;
|
||||||
} elseif (isset($url[$prefix]) && !$url[$prefix]) {
|
} elseif (isset($url[$prefix]) && !$url[$prefix]) {
|
||||||
unset($url[$prefix]);
|
unset($url[$prefix]);
|
||||||
|
@ -812,7 +812,6 @@ class Router {
|
||||||
|
|
||||||
if ($match = $self->routes[$i]->match($url)) {
|
if ($match = $self->routes[$i]->match($url)) {
|
||||||
$output = trim($match, '/');
|
$output = trim($match, '/');
|
||||||
$url = array();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$url = $originalUrl;
|
$url = $originalUrl;
|
||||||
|
@ -1537,14 +1536,12 @@ class CakeRoute {
|
||||||
$instance =& Router::getInstance();
|
$instance =& Router::getInstance();
|
||||||
$separator = $instance->named['separator'];
|
$separator = $instance->named['separator'];
|
||||||
|
|
||||||
if (!empty($params['named'])) {
|
if (!empty($params['named']) && is_array($params['named'])) {
|
||||||
if (is_array($params['named'])) {
|
|
||||||
$named = array();
|
$named = array();
|
||||||
foreach ($params['named'] as $key => $value) {
|
foreach ($params['named'] as $key => $value) {
|
||||||
$named[] = $key . $separator . $value;
|
$named[] = $key . $separator . $value;
|
||||||
}
|
}
|
||||||
$params['pass'] = $params['pass'] . '/' . implode('/', $named);;
|
$params['pass'] = $params['pass'] . '/' . implode('/', $named);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$out = $this->template;
|
$out = $this->template;
|
||||||
|
|
||||||
|
@ -1554,7 +1551,7 @@ class CakeRoute {
|
||||||
if (isset($params[$key])) {
|
if (isset($params[$key])) {
|
||||||
$string = $params[$key];
|
$string = $params[$key];
|
||||||
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
||||||
$key = $key . '/';
|
$key .= '/';
|
||||||
}
|
}
|
||||||
$search[] = ':' . $key;
|
$search[] = ':' . $key;
|
||||||
$replace[] = $string;
|
$replace[] = $string;
|
||||||
|
|
Loading…
Reference in a new issue