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;
|
$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);
|
$lengths = array_map('strlen', $this->keys);
|
||||||
$flipped = array_combine($this->keys, $lengths);
|
$flipped = array_combine($this->keys, $lengths);
|
||||||
arsort($flipped);
|
arsort($flipped);
|
||||||
$keys = array_keys($flipped);
|
$keys = array_keys($flipped);
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$string = null;
|
$string = null;
|
||||||
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 .= '/';
|
||||||
|
}
|
||||||
|
$search[] = ':' . $key;
|
||||||
|
$replace[] = $string;
|
||||||
}
|
}
|
||||||
$search[] = ':' . $key;
|
$out = str_replace($search, $replace, $out);
|
||||||
$replace[] = $string;
|
|
||||||
}
|
}
|
||||||
$out = str_replace($search, $replace, $out);
|
|
||||||
|
|
||||||
if (strpos($this->template, '*')) {
|
if (strpos($this->template, '*')) {
|
||||||
$out = str_replace('*', $params['pass'], $out);
|
$out = str_replace('*', $params['pass'], $out);
|
||||||
|
|
Loading…
Reference in a new issue