Symfony\Component\Console\Application::doRunCommand PHP Method

doRunCommand() protected method

If an event dispatcher has been attached to the application, events are also dispatched during the life-cycle of the command.
protected doRunCommand ( Command $command, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$command Symfony\Component\Console\Command\Command A Command instance
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
return integer 0 if everything went fine, or an error code
    protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
    {
        foreach ($command->getHelperSet() as $helper) {
            if ($helper instanceof InputAwareInterface) {
                $helper->setInput($input);
            }
        }
        if (null === $this->dispatcher) {
            try {
                return $command->run($input, $output);
            } catch (\Exception $e) {
                throw $e;
            } catch (\Throwable $e) {
                throw new FatalThrowableError($e);
            }
        }
        // bind before the console.command event, so the listeners have access to input options/arguments
        try {
            $command->mergeApplicationDefinition();
            $input->bind($command->getDefinition());
        } catch (ExceptionInterface $e) {
            // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
        }
        $event = new ConsoleCommandEvent($command, $input, $output);
        $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
        if ($event->commandShouldRun()) {
            try {
                $e = null;
                $exitCode = $command->run($input, $output);
            } catch (\Exception $x) {
                $e = $x;
            } catch (\Throwable $x) {
                $e = new FatalThrowableError($x);
            }
            if (null !== $e) {
                $event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
                $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
                if ($e !== $event->getException()) {
                    $x = $e = $event->getException();
                }
                $event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
                $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
                throw $x;
            }
        } else {
            $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
        }
        $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
        $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
        return $event->getExitCode();
    }

Usage Example

 /**
  * @override
  * @inheritDoc
  */
 protected function doRunCommand(SymfonyCommand $command, InputInterface $input, OutputInterface $output)
 {
     if ($command instanceof CommandInterface && $command->isAsync() === true) {
         $this->async = true;
     }
     return parent::doRunCommand($command, $input, $output);
 }
All Usage Examples Of Symfony\Component\Console\Application::doRunCommand