mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Moving addition of plugin and controller keys to Router instead of RouterRoute.
This commit is contained in:
parent
9e9559b350
commit
de0b90db4a
2 changed files with 7 additions and 14 deletions
|
@ -274,9 +274,7 @@ class Router {
|
|||
$self->__prefixes[] = $default['prefix'];
|
||||
$self->__prefixes = array_keys(array_flip($self->__prefixes));
|
||||
}
|
||||
if (!isset($default['action'])) {
|
||||
$default['action'] = 'index';
|
||||
}
|
||||
$default += array('action' => 'index', 'plugin' => null, 'controller' => null);
|
||||
$self->routes[] =& new RouterRoute($route, $default, $params);
|
||||
return $self->routes;
|
||||
}
|
||||
|
@ -1222,7 +1220,6 @@ class RouterRoute {
|
|||
return $this->_compiledRoute;
|
||||
}
|
||||
$this->_writeRoute($this->template, $this->defaults, $this->params);
|
||||
$this->defaults += array('plugin' => null, 'controller' => null);
|
||||
return $this->_compiledRoute;
|
||||
}
|
||||
/**
|
||||
|
@ -1407,8 +1404,6 @@ class RouterRoute {
|
|||
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
|
||||
|
||||
//*/
|
||||
|
||||
$url += array('controller' => null, 'plugin' => null);
|
||||
$defaults = $this->defaults;
|
||||
|
||||
if (isset($defaults['prefix'])) {
|
||||
|
|
|
@ -1949,7 +1949,7 @@ class RouterTest extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// SimpleTest::ignore('RouterTest');
|
||||
//SimpleTest::ignore('RouterTest');
|
||||
/**
|
||||
* Test case for RouterRoute
|
||||
*
|
||||
|
@ -2117,10 +2117,9 @@ class RouterRouteTestCase extends CakeTestCase {
|
|||
$this->assertPattern($result, '/posts/08/01/2007/title-of-post');
|
||||
$result = $route->parse('/posts/08/01/2007/title-of-post');
|
||||
|
||||
$this->assertEqual(count($result), 9);
|
||||
$this->assertEqual(count($result), 8);
|
||||
$this->assertEqual($result['controller'], 'posts');
|
||||
$this->assertEqual($result['action'], 'view');
|
||||
$this->assertEqual($result['plugin'], null);
|
||||
$this->assertEqual($result['year'], '2007');
|
||||
$this->assertEqual($result['month'], '08');
|
||||
$this->assertEqual($result['day'], '01');
|
||||
|
@ -2140,7 +2139,6 @@ class RouterRouteTestCase extends CakeTestCase {
|
|||
'controller' => 'pages',
|
||||
'action' => 'view',
|
||||
'extra' => null,
|
||||
'plugin' => null
|
||||
);
|
||||
$this->assertEqual($route->defaults, $expected);
|
||||
}
|
||||
|
@ -2200,7 +2198,7 @@ class RouterRouteTestCase extends CakeTestCase {
|
|||
'controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin'
|
||||
));
|
||||
|
||||
$url = array('plugin' => null, 'controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
|
||||
$url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
|
||||
$result = $route->match($url);
|
||||
$expected = '/admin/subscriptions/edit/1';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -2212,14 +2210,14 @@ class RouterRouteTestCase extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testMatchWithPatterns() {
|
||||
$route =& new RouterRoute('/:controller/:action/:id', array(), array('id' => '[0-9]+'));
|
||||
$route =& new RouterRoute('/:controller/:action/:id', array('plugin' => null), array('id' => '[0-9]+'));
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 'foo'));
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => '9'));
|
||||
$result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '9'));
|
||||
$this->assertEqual($result, '/posts/view/9');
|
||||
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => '922'));
|
||||
$result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '922'));
|
||||
$this->assertEqual($result, '/posts/view/922');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue