コード例 #1
0
 /**
  * Execute command - delegates call execute command to afsConsoleCommand class
  *
  * @param mixed $commands - array(multiple commands) or string(single command)
  * @return string
  * @author Sergey Startsev
  */
 public function execute($commands)
 {
     if ($commands != 'start') {
         $aCommands = !is_array($commands) ? (array) $commands : $commands;
         $result = array();
         if (!afsConsoleCommandHelper::create()->hasDeprecated($aCommands)) {
             $aCommands = afsConsoleCommandHelper::create()->prepare($aCommands);
             foreach ($aCommands as $command) {
                 foreach (afsConsoleCommandHelper::create()->getSubCommands($command) as $sub_command) {
                     $command_instance = afsConsoleCommand::create($sub_command)->setPrompt($this->getPrompt());
                     $result = array_merge($result, $command_instance->execute());
                     $this->lastExecReturnCode = $command_instance->getLastStatus();
                 }
             }
         } else {
             $result[] = afsRenderConsoleCommand::render("Some commands that you wanna execute has been deprecated");
             $result[] = afsRenderConsoleCommand::render("Deprecated commands: " . implode(', ', afsConsoleCommandHelper::create()->getDeprecated()));
         }
     } else {
         $result = $this->getDescription();
     }
     return implode('', $result);
 }
コード例 #2
0
 /**
  * Checking does command contains deprecated sub commands
  * for example:  sf cc && top && htop && irb
  *
  * @param mixed $command - array/string
  * @return boolean
  * @author Sergey Startsev
  */
 public function hasDeprecated($command)
 {
     $commands_array = !is_array($command) ? (array) $command : $command;
     foreach ($commands_array as $command_element) {
         foreach ($this->getSubCommands($command_element) as $sub_command) {
             $command_name = afsConsoleCommand::getCommandName(trim($sub_command));
             if ($command_name && in_array($command_name, $this->getDeprecated())) {
                 return true;
             }
         }
     }
     return false;
 }