Skip to content

Commit

Permalink
Updated routes.php so routes default routes only take the route param…
Browse files Browse the repository at this point in the history
…eter patterns they need.
  • Loading branch information
sgpinkus committed Feb 13, 2014
1 parent a554ac4 commit 37fd8dc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,25 @@
}
$pluginPattern = implode('|', $plugins);
$indexParams = ['action' => 'index'];
$match = ['prefix' => $prefixPattern, 'plugin' => $pluginPattern];
$pluginShortMatch = $match + [
$pluginShortMatch = [
'routeClass' => 'Cake\Routing\Route\PluginShortRoute',
'_name' => '_plugin._controller:index'
];

if ($prefixPattern && $pluginPattern) {
Router::connect('/:prefix/:plugin', $indexParams, $pluginShortMatch);
$match = ['prefix' => $prefixPattern, 'plugin' => $pluginPattern];
Router::connect('/:prefix/:plugin', $indexParams, $match + $pluginShortMatch);
Router::connect('/:prefix/:plugin/:controller', $indexParams, $match);
Router::connect('/:prefix/:plugin/:controller/:action/*', [], $match);
}
if ($pluginPattern) {
Router::connect('/:plugin', $indexParams, $pluginShortMatch);
$match = ['plugin' => $pluginPattern];
Router::connect('/:plugin', $indexParams, $match + $pluginShortMatch);
Router::connect('/:plugin/:controller', $indexParams, $match);
Router::connect('/:plugin/:controller/:action/*', [], $match);
}
if ($prefixPattern) {
$match = ['prefix' => $prefixPattern];
Router::connect('/:prefix/:controller', $indexParams, $match);
Router::connect('/:prefix/:controller/:action/*', [], $match);
}
Expand Down

0 comments on commit 37fd8dc

Please sign in to comment.