updating router admin handling, closes #3697 test added

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6281 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-12-30 19:53:21 +00:00
parent fdeb41a826
commit 48bf9e420d
2 changed files with 14 additions and 1 deletions

View file

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

View file

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