[Console] Added Command::isEnabled method that defines whether to add the command or not

This commit is contained in:
Jordi Boggiano 2011-06-29 00:18:03 +02:00
parent dccd2d560f
commit 536d9790c3
2 changed files with 18 additions and 0 deletions

View File

@ -388,6 +388,11 @@ class Application
{
$command->setApplication($this);
if (!$command->isEnabled()) {
$command->setApplication(null);
return;
}
$this->commands[$command->getName()] = $command;
foreach ($command->getAliases() as $alias) {

View File

@ -116,6 +116,19 @@ class Command
return $this->application;
}
/**
* Checks whether the command is enabled or not in the current environment
*
* Override this to check for x or y and return false if the command can not
* run properly under the current conditions.
*
* @return Boolean
*/
public function isEnabled()
{
return true;
}
/**
* Configures the current command.
*/