Made it slightly neater

This commit is contained in:
Mike Gibson 2014-03-10 15:01:52 +00:00
parent d40452b43d
commit 7205f5ec9c

View file

@ -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);