protected function execute(InputInterface $input, OutputInterface $output) { $exitCode = 0; $inputParameters = array('--no-tty' => !$this->tty); if ($input->getOption('no-tty')) { $inputParameters['--no-tty'] = $input->getOption('no-tty'); } if ($input->getOption('stop-on-error')) { $this->stopOnError = true; } $errorRemainingScripts = array('Remaining scripts:'); foreach ($this->batchScript as $index => $script) { if ($exitCode > 0 && $this->stopOnError) { $errorRemainingScripts[] = sprintf('%d) %s', $index + 1, $script); } else { $uniqueId = uniqid($this->getName() . ':'); $inputParameters['command'] = $uniqueId; $command = new ScriptCommand($uniqueId, $script); $command->setApplication($this->getApplication()); $scriptExitCode = $command->run(new ArrayInput($inputParameters), $output); if ($scriptExitCode > 0) { if ($this->stopOnError) { $exitCode = $scriptExitCode; } else { $exitCode = 1; } } } } if ($exitCode > 0 && $this->stopOnError) { $formattedBlock = $this->getHelper('formatter')->formatBlock($errorRemainingScripts, 'comment', true); $output->writeln($formattedBlock); } return $exitCode; }
protected function execute(InputInterface $input, OutputInterface $output) { $inputParameters = array('--no-tty' => false); if ($input->getOption('no-tty')) { $inputParameters['--no-tty'] = $input->getOption('no-tty'); } $uniqueId = uniqid($this->getName() . ':'); $inputParameters['command'] = $uniqueId; foreach ($this->allowedCommands as $allowedCommand) { if ($input->getOption($allowedCommand)) { $this->scriptOptions['command'] = $allowedCommand; } } $script = $this->scriptBuilder->build($this->scriptOptions); $command = new ScriptCommand($uniqueId, $script); $command->setApplication($this->getApplication()); $exitCode = $command->run(new ArrayInput($inputParameters), $output); return $exitCode; }