Skip to content

Commit

Permalink
use the defined route name in the routes shell
Browse files Browse the repository at this point in the history
in the column "Route Name" I would expect to get the name definied by named route if it exist.
  • Loading branch information
antograssiot committed Jul 27, 2015
1 parent a2938c3 commit 1b5d1fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Shell/RoutesShell.php
Expand Up @@ -38,7 +38,8 @@ public function main()
['Route name', 'URI template', 'Defaults']
];
foreach (Router::routes() as $route) {
$output[] = [$route->getName(), $route->template, json_encode($route->defaults)];
$name = isset($route->options['_name']) ? $route->options['_name'] : $route->getName();
$output[] = [$name, $route->template, json_encode($route->defaults)];
}
$this->helper('table')->output($output);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/TestCase/Shell/RoutesShellTest.php
Expand Up @@ -45,6 +45,7 @@ public function setUp()
$this->shell = new RoutesShell($this->io);
Router::connect('/articles/:action/*', ['controller' => 'Articles']);
Router::connect('/bake/:controller/:action', ['plugin' => 'Bake']);
Router::connect('/tests/:action/*', ['controller' => 'Tests'], ['_name' => 'testName']);
}

/**
Expand Down Expand Up @@ -75,6 +76,16 @@ public function testMain()
'articles:_action',
'/articles/:action/*',
'{"controller":"Articles","action":"index","plugin":null}'
]),
$this->contains([
'bake._controller:_action',
'/bake/:controller/:action',
'{"plugin":"Bake","action":"index"}',
]),
$this->contains([
'testName',
'/tests/:action/*',
'{"controller":"Tests","action":"index","plugin":null}'
])
)
);
Expand Down

0 comments on commit 1b5d1fe

Please sign in to comment.