mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Made it slightly neater
This commit is contained in:
parent
d40452b43d
commit
7205f5ec9c
1 changed files with 14 additions and 14 deletions
|
@ -517,28 +517,28 @@ class CakeRoute {
|
|||
}
|
||||
$out = $this->template;
|
||||
|
||||
$search = $replace = array();
|
||||
if(!empty($this->keys)) {
|
||||
|
||||
$search = $replace = array();
|
||||
|
||||
if(empty($this->keys)) {
|
||||
$keys = array();
|
||||
} else {
|
||||
$lengths = array_map('strlen', $this->keys);
|
||||
$flipped = array_combine($this->keys, $lengths);
|
||||
arsort($flipped);
|
||||
$keys = array_keys($flipped);
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$string = null;
|
||||
if (isset($params[$key])) {
|
||||
$string = $params[$key];
|
||||
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
||||
$key .= '/';
|
||||
foreach ($keys as $key) {
|
||||
$string = null;
|
||||
if (isset($params[$key])) {
|
||||
$string = $params[$key];
|
||||
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
||||
$key .= '/';
|
||||
}
|
||||
$search[] = ':' . $key;
|
||||
$replace[] = $string;
|
||||
}
|
||||
$search[] = ':' . $key;
|
||||
$replace[] = $string;
|
||||
$out = str_replace($search, $replace, $out);
|
||||
|
||||
}
|
||||
$out = str_replace($search, $replace, $out);
|
||||
|
||||
if (strpos($this->template, '*')) {
|
||||
$out = str_replace('*', $params['pass'], $out);
|
||||
|
|
Loading…
Reference in a new issue