From 60b30a0e9d2aab44af013bb2d4540386a03c5ee4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 18 Jun 2012 23:01:30 -0400 Subject: [PATCH] Remove Posts:index form of generating routes. We don't need 3 ways to do the same thing. 2 is plenty. --- lib/Cake/Routing/Router.php | 34 +------------------ .../Test/TestCase/Routing/DispatcherTest.php | 2 +- lib/Cake/Test/TestCase/Routing/RouterTest.php | 22 ------------ 3 files changed, 2 insertions(+), 56 deletions(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 8f6d949ad98..73c12201390 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -599,7 +599,7 @@ protected static function _applyUrlFilters($url) { * This usage does not use reverser routing. * - `Router::url(array('controller' => 'posts', 'action' => 'edit'));` Returns a url * generated through reverse routing. - * - `Router::url('Posts:index', array(...));` Returns a url generated through reverse + * - `Router::url('custom-name', array(...));` Returns a url generated through reverse * routing. This form allows you to leverage named routes. * * There are a few 'special' parameters that can change the final URL string that is generated @@ -641,16 +641,6 @@ public static function url($url = null, $options = array()) { $hasLeadingSlash = isset($url[0]) ? $url[0] === '/' : false; } - if ( - $urlType === 'string' && - strpos($url, ':') !== false && - strpos($url, '/') === false && - !$plainString - ) { - $url = static::_splitName($url, $options); - $urlType = 'array'; - } - // TODO refactor so there is less overhead // incurred on each URL generated. $request = static::getRequest(true); @@ -764,28 +754,6 @@ public static function url($url = null, $options = array()) { return $output . $frag; } -/** - * Splits a named route into the component parts. - * - * @param string $url The named route to split. - * @param array $options The array of parameter to merge with. - * @return array - */ - protected static function _splitName($url, $options) { - $plugin = null; - list($controller, $action) = explode(':', $url); - if (strpos($controller, '.') !== false) { - list($plugin, $controller) = explode('.', $controller); - } - $params = array( - 'plugin' => $plugin, - 'controller' => $controller, - 'action' => $action, - '_name' => $url - ); - return (array)$options + $params; - } - /** * Reverses a parsed parameter array into a string. Works similarly to Router::url(), but * Since parsed URL's contain additional 'pass' as well as 'url.url' keys. diff --git a/lib/Cake/Test/TestCase/Routing/DispatcherTest.php b/lib/Cake/Test/TestCase/Routing/DispatcherTest.php index 7b085157ba7..9204783ae10 100644 --- a/lib/Cake/Test/TestCase/Routing/DispatcherTest.php +++ b/lib/Cake/Test/TestCase/Routing/DispatcherTest.php @@ -491,7 +491,7 @@ public function testAdminDispatch() { $this->assertTrue($Dispatcher->controller->params['admin']); - $expected = '/admin/test_dispatch_pages/index/param:value/param2:value2'; + $expected = '/admin/test_dispatch_pages/index'; $this->assertSame($expected, $Dispatcher->controller->here); } diff --git a/lib/Cake/Test/TestCase/Routing/RouterTest.php b/lib/Cake/Test/TestCase/Routing/RouterTest.php index 19fcaaa4e30..8c074111cca 100644 --- a/lib/Cake/Test/TestCase/Routing/RouterTest.php +++ b/lib/Cake/Test/TestCase/Routing/RouterTest.php @@ -764,28 +764,6 @@ public function testUrlGenerationWithExtensions() { $this->assertEquals($expected, $result); } -/** - * Test url generation using compact route names. - * - * @return void - */ - public function testUrlGenerationWithCompactForm() { - Router::connect('/:plugin/:controller/:action/*'); - Router::connect('/:controller/:action/*'); - - $url = Router::url('posts:index'); - $this->assertEquals('/posts/index', $url); - - $url = Router::url('posts:view', array(2)); - $this->assertEquals('/posts/view/2', $url); - - $url = Router::url('posts:index', array('page' => 1, 'dir' => 'asc')); - $this->assertEquals('/posts/index?page=1&dir=asc', $url); - - $url = Router::url('asset_compress.posts:view', array(2)); - $this->assertEquals('/asset_compress/posts/view/2', $url); - } - /** * Test url generation with named routes. */