Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove Posts:index form of generating routes.
We don't need 3 ways to do the same thing.  2 is plenty.
  • Loading branch information
markstory committed Jul 4, 2012
1 parent 2b35abe commit 60b30a0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 56 deletions.
34 changes: 1 addition & 33 deletions lib/Cake/Routing/Router.php
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Routing/DispatcherTest.php
Expand Up @@ -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);
}

Expand Down
22 changes: 0 additions & 22 deletions lib/Cake/Test/TestCase/Routing/RouterTest.php
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 60b30a0

Please sign in to comment.