/** * 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); }
/** * Testing on non existed helper method * * @depends testClassExisting * @expectedException afsConsoleCommandHelperException * * @author Sergey Startsev */ public function testNotExistedConsoleCommandHelperMethod() { afsConsoleCommandHelper::create()->testNonExistedMethod(); }