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[] = $default['prefix'];
|
||||||
$self->__prefixes = array_keys(array_flip($self->__prefixes));
|
$self->__prefixes = array_keys(array_flip($self->__prefixes));
|
||||||
}
|
}
|
||||||
if (!isset($default['action'])) {
|
$default += array('action' => 'index', 'plugin' => null, 'controller' => null);
|
||||||
$default['action'] = 'index';
|
|
||||||
}
|
|
||||||
$self->routes[] =& new RouterRoute($route, $default, $params);
|
$self->routes[] =& new RouterRoute($route, $default, $params);
|
||||||
return $self->routes;
|
return $self->routes;
|
||||||
}
|
}
|
||||||
|
@ -1222,7 +1220,6 @@ class RouterRoute {
|
||||||
return $this->_compiledRoute;
|
return $this->_compiledRoute;
|
||||||
}
|
}
|
||||||
$this->_writeRoute($this->template, $this->defaults, $this->params);
|
$this->_writeRoute($this->template, $this->defaults, $this->params);
|
||||||
$this->defaults += array('plugin' => null, 'controller' => null);
|
|
||||||
return $this->_compiledRoute;
|
return $this->_compiledRoute;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1407,8 +1404,6 @@ class RouterRoute {
|
||||||
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
|
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
|
||||||
|
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
$url += array('controller' => null, 'plugin' => null);
|
|
||||||
$defaults = $this->defaults;
|
$defaults = $this->defaults;
|
||||||
|
|
||||||
if (isset($defaults['prefix'])) {
|
if (isset($defaults['prefix'])) {
|
||||||
|
|
|
@ -1949,7 +1949,7 @@ class RouterTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimpleTest::ignore('RouterTest');
|
//SimpleTest::ignore('RouterTest');
|
||||||
/**
|
/**
|
||||||
* Test case for RouterRoute
|
* Test case for RouterRoute
|
||||||
*
|
*
|
||||||
|
@ -2117,10 +2117,9 @@ class RouterRouteTestCase extends CakeTestCase {
|
||||||
$this->assertPattern($result, '/posts/08/01/2007/title-of-post');
|
$this->assertPattern($result, '/posts/08/01/2007/title-of-post');
|
||||||
$result = $route->parse('/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['controller'], 'posts');
|
||||||
$this->assertEqual($result['action'], 'view');
|
$this->assertEqual($result['action'], 'view');
|
||||||
$this->assertEqual($result['plugin'], null);
|
|
||||||
$this->assertEqual($result['year'], '2007');
|
$this->assertEqual($result['year'], '2007');
|
||||||
$this->assertEqual($result['month'], '08');
|
$this->assertEqual($result['month'], '08');
|
||||||
$this->assertEqual($result['day'], '01');
|
$this->assertEqual($result['day'], '01');
|
||||||
|
@ -2140,7 +2139,6 @@ class RouterRouteTestCase extends CakeTestCase {
|
||||||
'controller' => 'pages',
|
'controller' => 'pages',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
'extra' => null,
|
'extra' => null,
|
||||||
'plugin' => null
|
|
||||||
);
|
);
|
||||||
$this->assertEqual($route->defaults, $expected);
|
$this->assertEqual($route->defaults, $expected);
|
||||||
}
|
}
|
||||||
|
@ -2200,7 +2198,7 @@ class RouterRouteTestCase extends CakeTestCase {
|
||||||
'controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin'
|
'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);
|
$result = $route->match($url);
|
||||||
$expected = '/admin/subscriptions/edit/1';
|
$expected = '/admin/subscriptions/edit/1';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
@ -2212,14 +2210,14 @@ class RouterRouteTestCase extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testMatchWithPatterns() {
|
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'));
|
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 'foo'));
|
||||||
$this->assertFalse($result);
|
$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');
|
$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');
|
$this->assertEqual($result, '/posts/view/922');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue