public function route($cmd)
{
$this->_controllerName = null;
$this->_actionName = null;
$command = $cmd ?: 'help:list';
if (isset($this->_commandAliases[strtolower($command)])) {
$command = $this->_commandAliases[strtolower($command)];
}
$parts = explode(':', $command);
switch (count($parts)) {
case 1:
$controllerName = $parts[0];
$actionName = null;
break;
case 2:
$controllerName = $parts[0];
$actionName = $parts[1];
break;
default:
return false;
}
if ($this->_guessCommand && strlen($controllerName) <= 3) {
$controllers = $this->_getControllers();
$controllerName = $this->crossword->guess($controllers, $controllerName);
if (!$controllerName) {
return false;
}
} else {
$controllerName = Text::camelize($controllerName);
}
if ($actionName === null) {
$commands = $this->_getCommands($controllerName);
if (count($commands) === 1) {
$actionName = $commands[0];
} else {
return false;
}
} else {
if ($this->_guessCommand && strlen($actionName) <= 2) {
$commands = $this->_getCommands($controllerName);
$actionName = $this->crossword->guess($commands, $actionName);
if (!$actionName) {
return false;
}
} else {
$actionName = lcfirst(Text::camelize($actionName));
}
}
$this->_controllerName = $controllerName;
$this->_actionName = $actionName;
return true;
}