/** * 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 * @return void * @throws \TYPO3\FLOW3\Mvc\Exception\InvalidCommandIdentifierException */ public function exitIfCompiletimeCommandWasNotCalledCorrectly($runlevel) { if ($runlevel === 'Runtime') { $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); } } }
/** * Displays a human readable, partly beautified version of the given exception * and stops the application, return a non-zero exit code. * * @static * @param \Exception $exception * @return void */ public static function writeResponseAndExit(\Exception $exception) { $response = new Response(); $exceptionMessage = ''; $exceptionReference = "\n<b>More Information</b>\n"; $exceptionReference .= " Exception code #" . $exception->getCode() . "\n"; $exceptionReference .= " File " . $exception->getFile() . ($exception->getLine() ? ' line ' . $exception->getLine() : '') . "\n"; $exceptionReference .= $exception instanceof \TYPO3\FLOW3\Exception ? " Exception reference #" . $exception->getReferenceCode() . "\n" : ''; foreach (explode(chr(10), wordwrap($exception->getMessage(), 73)) as $messageLine) { $exceptionMessage .= " {$messageLine}\n"; } $response->setContent(sprintf("<b>Uncaught Exception</b>\n%s%s\n", $exceptionMessage, $exceptionReference)); $response->send(); exit(1); }
/** * Sends the response and exits the CLI without any further code execution * Should be used for commands that flush code caches. * * @param integer $exitCode Exit code to return on exit * @return void */ protected function sendAndExit($exitCode = 0) { $this->response->send(); exit($exitCode); }