Skip to content

Commit 2307761

Browse files
committed
Fix named routes not being indexed for reverse routing.
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
1 parent 96cb76b commit 2307761

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/Routing/Route/Route.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ class Route {
9090
*
9191
* ### Options
9292
*
93-
* - `_name` - By using $options['_name'] a specific name can be
94-
* given to a route. Otherwise a route name will be generated.
9593
* - `_ext` - Defines the extensions used for this route.
9694
* - `pass` - Copies the listed parameters into params['pass'].
9795
*
@@ -103,9 +101,6 @@ public function __construct($template, $defaults = [], array $options = []) {
103101
$this->template = $template;
104102
$this->defaults = (array)$defaults;
105103
$this->options = $options;
106-
if (isset($this->options['_name'])) {
107-
$this->_name = $this->options['_name'];
108-
}
109104
if (isset($this->defaults['[method]'])) {
110105
$this->defaults['_method'] = $this->defaults['[method]'];
111106
unset($this->defaults['[method]']);

tests/TestCase/Routing/Route/RouteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ public function testParseTrailingUTF8() {
888888
*/
889889
public function testGetName() {
890890
$route = new Route('/foo/bar', array(), array('_name' => 'testing'));
891-
$this->assertEquals('testing', $route->getName());
891+
$this->assertEquals('', $route->getName());
892892

893893
$route = new Route('/:controller/:action');
894894
$this->assertEquals('_controller:_action', $route->getName());

tests/TestCase/Routing/RouteCollectionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ public function testMatchNamed() {
183183

184184
$result = $this->collection->match(['_name' => 'article:view', 'id' => '2'], $context);
185185
$this->assertEquals('/b/2', $result);
186+
187+
$result = $this->collection->match(['plugin' => null, 'controller' => 'Articles', 'action' => 'view', 'id' => '2'], $context);
188+
$this->assertEquals('b/2', $result);
186189
}
187190

188191
/**

0 commit comments

Comments
 (0)