/** * Checks if compile time command was not recognized as such, then runlevel was * booted but it turned out that in fact the command is a compile time command. * * This happens if the user doesn't specify the full command identifier. * * @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants * @return void */ public function exitIfCompiletimeCommandWasNotCalledCorrectly($runlevel) { if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) { return; } $command = $this->request->getCommand(); if ($this->bootstrap->isCompiletimeCommand($command->getCommandIdentifier())) { $this->response->appendContent(sprintf("<b>Unrecognized Command</b>\n\n" . "Sorry, but he command \"%s\" must be specified by its full command\n" . "identifier because it is a compile time command which cannot be resolved\n" . "from an abbreviated command identifier.\n\n", $command->getCommandIdentifier())); $this->response->send(); $this->shutdown($runlevel); exit(1); } }
/** * Calls the specified command method and passes the arguments. * * If the command returns a string, it is appended to the content in the * response object. If the command doesn't return anything and a valid * view exists, the view is rendered automatically. * * @return void */ protected function callCommandMethod() { $preparedArguments = []; /** @var Argument $argument */ foreach ($this->arguments as $argument) { $preparedArguments[] = $argument->getValue(); } $command = new Command(get_class($this), $this->request->getControllerCommandName()); if ($command->isDeprecated()) { $suggestedCommandMessage = ''; $relatedCommandIdentifiers = $command->getRelatedCommandIdentifiers(); if ($relatedCommandIdentifiers !== []) { $suggestedCommandMessage = sprintf(', use the following command%s instead: %s', count($relatedCommandIdentifiers) > 1 ? 's' : '', implode(', ', $relatedCommandIdentifiers)); } $this->outputLine('<b>Warning:</b> This command is <b>DEPRECATED</b>%s%s', [$suggestedCommandMessage, PHP_EOL]); } $commandResult = call_user_func_array([$this, $this->commandMethodName], $preparedArguments); if (is_string($commandResult) && strlen($commandResult) > 0) { $this->response->appendContent($commandResult); } elseif (is_object($commandResult) && method_exists($commandResult, '__toString')) { $this->response->appendContent((string) $commandResult); } }