Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RunCommandMessageHandler.php

function RunCommandMessageHandler::__invoke

File

vendor/symfony/console/Messenger/RunCommandMessageHandler.php, line 30

Class

RunCommandMessageHandler
@author Kevin Bond <kevinbond@gmail.com>

Namespace

Symfony\Component\Console\Messenger

Code

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());
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal