/**
* Class CallCommandListener
+ *
* @package Drupal\Console\Core\EventSubscriber
*/
class CallCommandListener implements EventSubscriberInterface
/**
* CallCommandListener constructor.
+ *
* @param ChainQueue $chainQueue
*/
public function __construct(ChainQueue $chainQueue)
$io = new DrupalStyle($event->getInput(), $event->getOutput());
if (!$command instanceof Command) {
- return;
+ return 0;
}
$application = $command->getApplication();
$commands = $this->chainQueue->getCommands();
if (!$commands) {
- return;
+ return 0;
}
foreach ($commands as $chainedCommand) {
}
$io->text($chainedCommand['name']);
- $callCommand->run($input, $io);
+ $allowFailure = array_key_exists('allow_failure', $chainedCommand)?$chainedCommand['allow_failure']:false;
+ try {
+ $callCommand->run($input, $io);
+ } catch (\Exception $e) {
+ if (!$allowFailure) {
+ $io->error($e->getMessage());
+ return 1;
+ }
+ }
}
}