Skip to content

Commit

Permalink
Fix named routes not being indexed for reverse routing.
Browse files Browse the repository at this point in the history
While *generally* people will be using the named route, we also need to
store routes based on their normal name. This allows features like
PaginatorHelper to interact with custom routes.

Refs #4126
  • Loading branch information
markstory committed Aug 1, 2014
1 parent 96cb76b commit 2307761
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/Routing/Route/Route.php
Expand Up @@ -90,8 +90,6 @@ class Route {
*
* ### Options
*
* - `_name` - By using $options['_name'] a specific name can be
* given to a route. Otherwise a route name will be generated.
* - `_ext` - Defines the extensions used for this route.
* - `pass` - Copies the listed parameters into params['pass'].
*
Expand All @@ -103,9 +101,6 @@ public function __construct($template, $defaults = [], array $options = []) {
$this->template = $template;
$this->defaults = (array)$defaults;
$this->options = $options;
if (isset($this->options['_name'])) {
$this->_name = $this->options['_name'];
}
if (isset($this->defaults['[method]'])) {
$this->defaults['_method'] = $this->defaults['[method]'];
unset($this->defaults['[method]']);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/Route/RouteTest.php
Expand Up @@ -888,7 +888,7 @@ public function testParseTrailingUTF8() {
*/
public function testGetName() {
$route = new Route('/foo/bar', array(), array('_name' => 'testing'));
$this->assertEquals('testing', $route->getName());
$this->assertEquals('', $route->getName());

$route = new Route('/:controller/:action');
$this->assertEquals('_controller:_action', $route->getName());
Expand Down
3 changes: 3 additions & 0 deletions tests/TestCase/Routing/RouteCollectionTest.php
Expand Up @@ -183,6 +183,9 @@ public function testMatchNamed() {

$result = $this->collection->match(['_name' => 'article:view', 'id' => '2'], $context);
$this->assertEquals('/b/2', $result);

$result = $this->collection->match(['plugin' => null, 'controller' => 'Articles', 'action' => 'view', 'id' => '2'], $context);
$this->assertEquals('b/2', $result);
}

/**
Expand Down

0 comments on commit 2307761

Please sign in to comment.