UnknownCommandException represents an exception caused by incorrect usage of a console command.
Property Details Method Details__construct()
public methodConstruct the exception.
public void __construct ( $route, $application, $code = 0, $previous = null ) $route stringThe route of the command that could not be found.
$application yii\console\ApplicationThe console application instance involved.
$code integerThe Exception code.
$previous Throwable|nullThe previous exception used for the exception chaining.
public function __construct($route, $application, $code = 0, $previous = null)
{
$this->command = $route;
$this->application = $application;
parent::__construct("Unknown command \"$route\".", $code, $previous);
}
public function getName()
{
return 'Unknown command';
}
getSuggestedAlternatives()
public methodSuggest alternative commands for $command based on string similarity.
Alternatives are searched using the following steps:
$command
See also https://www.php.net/manual/en/function.levenshtein.php.
public function getSuggestedAlternatives()
{
$help = $this->application->createController('help');
if ($help === false || $this->command === '') {
return [];
}
/** @var $helpController HelpController */
list($helpController, $actionID) = $help;
$availableActions = [];
foreach ($helpController->getCommands() as $command) {
$result = $this->application->createController($command);
/** @var $controller Controller */
list($controller, $actionID) = $result;
if ($controller->createAction($controller->defaultAction) !== null) {
// add the command itself (default action)
$availableActions[] = $command;
}
// add all actions of this controller
$actions = $helpController->getActions($controller);
$prefix = $controller->getUniqueId();
foreach ($actions as $action) {
$availableActions[] = $prefix . '/' . $action;
}
}
return $this->filterBySimilarity($availableActions, $this->command);
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4