Skip to content

Commit

Permalink
Fix route commands in ConsoleShell.
Browse files Browse the repository at this point in the history
Apply patch from 'Ludovic Pouzenc' to fix route features in the console
shell.

Fixes #3096
  • Loading branch information
markstory committed Aug 4, 2012
1 parent 73b1c0a commit d7f1bf5
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/Cake/Console/Command/ConsoleShell.php
Expand Up @@ -64,7 +64,14 @@ public function startup() {
foreach ($this->models as $model) {
$this->out(" - {$model}");
}
$this->_loadRoutes();

if (!$this->_loadRoutes()) {
$message = __d(
'cake_console',
'There was an error loading the routes config. Please check that the file exists and contains no errors.'
);
$this->err($message);
}
}

/**
Expand Down Expand Up @@ -291,16 +298,14 @@ public function main($command = null) {
}
break;
case (preg_match("/^routes\s+reload/i", $command, $tmp) == true):
$router = Router::getInstance();
if (!$this->_loadRoutes()) {
$this->out(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
$this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
break;
}
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count($router->routes)));
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes)));
break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
$router = Router::getInstance();
$this->out(implode("\n", Hash::extract($router->routes, '{n}.0')));
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
break;
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
if ($url = eval('return array' . $tmp[1] . ';')) {
Expand Down Expand Up @@ -345,14 +350,6 @@ protected function _loadRoutes() {
CakePlugin::routes();

Router::parse('/');

foreach (array_keys(Router::getNamedExpressions()) as $var) {
unset(${$var});
}

foreach (Router::$routes as $route) {
$route->compile();
}
return true;
}

Expand Down

0 comments on commit d7f1bf5

Please sign in to comment.