function RunCommandMessageHandler::__invoke
File
-
vendor/
symfony/ console/ Messenger/ RunCommandMessageHandler.php, line 30
Class
- RunCommandMessageHandler
- @author Kevin Bond <kevinbond@gmail.com>
Namespace
Symfony\Component\Console\MessengerCode
public function __invoke(RunCommandMessage $message) : RunCommandContext {
$input = new StringInput($message->input);
$output = new BufferedOutput();
$this->application
->setCatchExceptions($message->catchExceptions);
try {
$exitCode = $this->application
->run($input, $output);
} catch (\Throwable $e) {
throw new RunCommandFailedException($e, new RunCommandContext($message, Command::FAILURE, $output->fetch()));
}
if ($message->throwOnFailure && Command::SUCCESS !== $exitCode) {
throw new RunCommandFailedException(\sprintf('Command "%s" exited with code "%s".', $message->input, $exitCode), new RunCommandContext($message, $exitCode, $output->fetch()));
}
return new RunCommandContext($message, $exitCode, $output->fetch());
}