think\console\Command::setConsole PHP Method

setConsole() public method

设置控制台
public setConsole ( Console $console = null )
$console think\Console
    public function setConsole(Console $console = null)
    {
        $this->console = $console;
    }

Usage Example

Beispiel #1
0
 /**
  * 添加一个指令
  * @param Command $command
  * @return Command
  */
 public function add(Command $command)
 {
     $command->setConsole($this);
     if (!$command->isEnabled()) {
         $command->setConsole(null);
         return null;
     }
     if (null === $command->getDefinition()) {
         throw new \LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command)));
     }
     $this->commands[$command->getName()] = $command;
     foreach ($command->getAliases() as $alias) {
         $this->commands[$alias] = $command;
     }
     return $command;
 }