diff --git a/cake/libs/router.php b/cake/libs/router.php index 1cea57ec6..c7f94bcd5 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -210,10 +210,16 @@ class Router extends Object { if (!empty($default) && empty($default['action'])) { $default['action'] = 'index'; } + + if(isset($default[$admin])) { + $default['prefix'] = $admin; + } + if (isset($default['prefix'])) { $_this->__prefixes[] = $default['prefix']; $_this->__prefixes = array_unique($_this->__prefixes); } + if ($route = $_this->writeRoute($route, $default, $params)) { $_this->routes[] = $route; } @@ -716,7 +722,7 @@ class Router extends Object { } } $named = $args = array(); - $skip = array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix', Configure::read('Routing.admin')); + $skip = array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix', $admin); $keys = array_values(array_diff(array_keys($url), $skip)); $count = count($keys); diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 6df16cf2b..5616b0c52 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -641,6 +641,13 @@ class RouterTest extends UnitTestCase { $this->router->reload(); $this->router->parse('/'); + $this->router->reload(); + $this->router->connect('/admin', array('admin' => true, 'controller' => 'users')); + $result = $this->router->parse('/admin'); + $expected = array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'users', 'action' => 'index', 'admin' => true, 'prefix' => 'admin'); + $this->assertEqual($result, $expected); + + $result = $this->router->url(array('admin' => true, 'controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2')); $expected = '/admin/posts/index/0?var=test&var2=test2'; $this->assertEqual($result, $expected);