Router fix for breaking out of plugins (Ticket #3106)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5577 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-08-24 13:11:31 +00:00
parent 73909d0617
commit 1326d20792
2 changed files with 27 additions and 0 deletions

View file

@ -674,8 +674,17 @@ class Router extends Object {
}
}
$plugin = false;
if (array_key_exists('plugin', $url)) {
$plugin = $url['plugin'];
}
$url = am(array('controller' => $params['controller'], 'plugin' => $params['plugin']), Set::filter($url, true));
if ($plugin !== false) {
$url['plugin'] = $plugin;
}
if (isset($url['ext'])) {
$extension = '.' . $url['ext'];
unset($url['ext']);

View file

@ -368,6 +368,24 @@ class RouterTest extends UnitTestCase {
$result = $this->router->url(array('admin' => true, 'controller' => 'pages', 'action' => 'view', 'my-page'));
$expected = '/page/my-page';
$this->assertEqual($result, $expected);
$this->router->reload();
$this->router->setRequestInfo(array(
array(
'pass' => array(), 'action' => 'index', 'plugin' => 'myplugin', 'controller' => 'mycontroller',
'admin' => false, 'url' => array('url' => array()), 'bare' => 0, 'webservices' => ''
),
array(
'base' => '/', 'here' => '/',
'webroot' => '/', 'passedArgs' => array(), 'namedArgs' => array(),
'webservices' => null
)
));
$result = $this->router->url(array('plugin' => null, 'controller' => 'myothercontroller'));
$expected = '/myothercontroller/';
$this->assertEqual($result, $expected);
}
function testUrlGenerationWithExtensions() {