SensioLabs\Melody\Console\Command\RunCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $melody = new Melody();
        $configRepository = new UserConfigurationRepository();
        $userConfig = $configRepository->load();
        $processHelper = $this->getHelperSet()->get('process');
        $cliExecutor = function (Process $process, $verbose) use($output, $processHelper) {
            if ($verbose) {
                // print debugging output for the build process
                $processHelper->mustRun($output, $process);
            } else {
                $callback = function ($type, $text) use($output) {
                    if ($type == 'out' && $output instanceof ConsoleOutputInterface) {
                        $output = $output->getErrorOutput();
                    }
                    $output->write($text);
                };
                return $process->run($callback);
            }
        };
        $runConfiguration = new RunConfiguration($input->getOption('no-cache'), $input->getOption('prefer-source'), $input->getOption('trust'));
        $script = $input->getArgument('script');
        $arguments = $input->getArgument('arguments');
        while (true) {
            try {
                $melody->run($script, $arguments, $runConfiguration, $userConfig, $cliExecutor);
                return 0;
            } catch (TrustException $e) {
                if (false === $this->confirmTrust($e->getResource(), $input, $output)) {
                    $output->writeln('<error>Operation aborted by the user.</error>');
                    return 1;
                }
                $userConfig->addTrustedSignature($e->getResource()->getSignature());
                $configRepository->save($userConfig);
            }
        }
    }