mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing code from RouterRoute::__mapRoute. All tests passing.
This commit is contained in:
parent
b242dc9531
commit
0834cb47ab
1 changed files with 12 additions and 16 deletions
|
@ -1452,49 +1452,45 @@ class RouterRoute {
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function __mapRoute($params) {
|
function __mapRoute($params) {
|
||||||
if (isset($params['plugin']) && isset($params['controller']) && $params['plugin'] === $params['controller']) {
|
if (isset($params['plugin'], $params['controller']) && $params['plugin'] === $params['controller']) {
|
||||||
unset($params['controller']);
|
unset($params['controller']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params['prefix']) && isset($params['action'])) {
|
if (isset($params['prefix'], $params['action'])) {
|
||||||
$params['action'] = str_replace($params['prefix'] . '_', '', $params['action']);
|
$params['action'] = str_replace($params['prefix'] . '_', '', $params['action']);
|
||||||
unset($params['prefix']);
|
unset($params['prefix']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params['pass']) && is_array($params['pass'])) {
|
if (is_array($params['pass'])) {
|
||||||
$params['pass'] = implode('/', Set::filter($params['pass'], true));
|
$params['pass'] = implode('/', $params['pass']);
|
||||||
} elseif (!isset($params['pass'])) {
|
|
||||||
$params['pass'] = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$instance = Router::getInstance();
|
$instance =& Router::getInstance();
|
||||||
$separator = $instance->named['separator'];
|
$separator = $instance->named['separator'];
|
||||||
|
|
||||||
if (isset($params['named'])) {
|
if (isset($params['named'])) {
|
||||||
if (is_array($params['named'])) {
|
if (is_array($params['named'])) {
|
||||||
$count = count($params['named']);
|
|
||||||
$keys = array_keys($params['named']);
|
|
||||||
$named = array();
|
$named = array();
|
||||||
|
foreach ($params['named'] as $key => $value) {
|
||||||
for ($i = 0; $i < $count; $i++) {
|
$named[] = $key . $separator . $value;
|
||||||
$named[] = $keys[$i] . $separator . $params['named'][$keys[$i]];
|
|
||||||
}
|
}
|
||||||
$params['named'] = join('/', $named);
|
$params['pass'] = $params['pass'] . '/' . implode('/', $named);;
|
||||||
}
|
}
|
||||||
$params['pass'] = str_replace('//', '/', $params['pass'] . '/' . $params['named']);
|
|
||||||
}
|
}
|
||||||
$out = $this->template;
|
$out = $this->template;
|
||||||
|
|
||||||
|
$search = $replace = array();
|
||||||
foreach ($this->keys as $key) {
|
foreach ($this->keys as $key) {
|
||||||
$string = null;
|
$string = null;
|
||||||
if (isset($params[$key])) {
|
if (isset($params[$key])) {
|
||||||
$string = $params[$key];
|
$string = $params[$key];
|
||||||
unset($params[$key]);
|
|
||||||
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
||||||
$key = $key . '/';
|
$key = $key . '/';
|
||||||
}
|
}
|
||||||
$out = str_replace(':' . $key, $string, $out);
|
$search[] = ':' . $key;
|
||||||
|
$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