@param  InputInterface $input
@param  OutputInterface $output

@return StateInterface|null
487953
private function activateTransition(InputInterface $input, OutputInterface $output)
    {
        $next_state = null;
        foreach ($this->state_transitions->get($output->getCurrentState()) as $transition) {
            if ($transition->isActivatedBy($input, $output)) {
                if (is_null($next_state)) {
                    $next_state = $this->states->get($transition->getTo());
                    continue;
                }
                throw new ExecutionError(
                    'Trying to activate more than one transition at a time. Transition: '.
                    $output->getCurrentState().' -> '.$next_state->getName().' was activated first. '.
                    'Now '.$transition->getFrom().' -> '.$transition->getTo().' is being activated too.'
                );
            }
        }
        return $next_state;
    }
623294
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        $outputFile = null;
        if ($file = $input->getOption('output-file')) {
            $outputFile = $file;
        }
        $this->service($input->getArgument($this->argument), $outputFile);
    }
419662
public function execute(InputInterface $input, OutputInterface $output)
    {
        $argument = $input->getArgument($this->argumentName);
        $path = $this->basePath.'/'.$argument.'.php';

        if ($input->hasOption('restful') && $input->getOption('restful') == true) {
            $this->restful = true;
        } else {
            $this->restful = false;
        }

        $response = $this->runFileGeneratorCommand($path, $argument);

        if ($response === true) {
            $this->type ?: $this->type = 'Command';
            $output->writeln(ucfirst($this->type).' created successfully');

            return;
        }
        $output->writeln($response);
    }
850737
protected function execute(InputInterface $input, OutputInterface $output)
    {
        return $this->getRunner($input, $output)->run() ? 0 : -1;
    }
689124
public function execute(InputInterface $input, OutputInterface $output)
    {
        $uri = $input->getArgument('uri');

        $data = $input->getParameterOption(['--data', '-d']);
        if (file_exists($data)) {
            $data = file_get_contents($data);
        }

        client()->createRequest($uri);

        if (false === strpos(client()->getProtocol(), 'http') && empty($data)) {
            $data = ' ';
        }

        $response = client()->send($data);

        if ($input->hasParameterOption(['--json'])) {
            $json = $response->getContents();
            $header = '';
            foreach ($response->getHeaders() as $key => $value) {
                $header .= $key.': '.$response->getHeaderLine($key).PHP_EOL;
            }
            $response = $header."\r\n".json_encode(json_decode($json, true), JSON_PRETTY_PRINT);
        } elseif (false !== strpos(client()->getProtocol(), 'http')) {
            $response = (string) $response;
        } else {
            $response = $response->getContents();
        }

        $output->writeln($response);

        return 0;
    }
1014081
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);

        $this->setOutput($output);
        $this->setVerbosity($output->getVerbosity());

        if ($input->getOption('child') && $output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
            $this->setVerbosity(self::VERBOSITY_CHILD);
        }

        $this->getContainer()->get('ez_migration_bundle.step_executed_listener.tracing')->setOutput($output);

        $migrationService = $this->getMigrationService();

        $force = $input->getOption('force');

        $toExecute = $this->buildMigrationsList($input->getOption('path'), $migrationService, $force);

        if (!count($toExecute)) {
            $output->writeln('<info>No migrations to execute</info>');
            return 0;
        }

        $this->printMigrationsList($toExecute, $input, $output);

        if (!$input->getOption('child')) {
            // ask user for confirmation to make changes
            if (!$this->askForConfirmation($input, $output)) {
                return 0;
            }
        }

        if ($input->getOption('separate-process')) {
            $builder = new ProcessBuilder();
            $executableFinder = new PhpExecutableFinder();
            if (false !== $php = $executableFinder->find()) {
                $builder->setPrefix($php);
            }
            $builderArgs = $this->createChildProcessArgs($input);
        }

        // For cli scripts, this means: do not die if anyone yanks out our stdout.
        if ($input->getOption('survive-disconnected-tty')) {
            ignore_user_abort(true);
        }

        // allow forcing handling of sigchild. Useful on eg. Debian and Ubuntu
        if ($input->getOption('force-sigchild-enabled')) {
            Process::forceSigchildEnabled(true);
        }

        $aborted = false;
        $executed = 0;
        $failed = 0;
        $skipped = 0;
        $total = count($toExecute);

        /** @var MigrationDefinition $migrationDefinition */
        foreach ($toExecute as $name => $migrationDefinition) {

            // let's skip migrations that we know are invalid - user was warned and he decided to proceed anyway
            if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
                $output->writeln("<comment>Skipping $name</comment>");
                $skipped++;
                continue;
            }

            $this->writeln("<info>Processing $name</info>");

            if ($input->getOption('separate-process')) {

                try {
                    $this->executeMigrationInSeparateProcess($migrationDefinition, $migrationService, $builder, $builderArgs);

                    $executed++;
                } catch (\Exception $e) {
                    $failed++;


                    $errorMessage = $e->getMessage();
                    // we probably have already echoed the error message while the subprocess was executing, avoid repeating it
                    if ($errorMessage != $this->subProcessErrorString) {
                        if ($e instanceof AfterMigrationExecutionException) {
                            $errorMessage = "Failure after migration end! Reason: " . $errorMessage;
                        } else {
                            $errorMessage = "Migration failed! Reason: " . $errorMessage;
                        }

                        $this->writeErrorln("\n<error>$errorMessage</error>");
                    }

                    if (!$input->getOption('ignore-failures')) {
                        $aborted = true;
                        break;
                    }
                }

            } else {

                try {
                    $this->executeMigrationInProcess($migrationDefinition, $force, $migrationService, $input);

                    $executed++;
                } catch (\Exception $e) {
                    $failed++;

                    $this->writeErrorln("\n<error>Migration failed! Reason: " . $e->getMessage() . "</error>");

                    if (!$input->getOption('ignore-failures')) {
                        $aborted = true;
                        break;
                    }
                }

            }
        }

        $missed = $total - $executed - $failed - $skipped;

        if ($aborted) {
            if ($missed > 0) {
                $this->writeErrorln("\n<error>Migration execution aborted</error>");
            }
        } else {
            // NB: as per the Sf doc at https://symfony.com/doc/2.7/console/calling_commands.html, the 'cache:clear'
            // command should be run 'at the end', as they change some class definitions
            if ($input->getOption('clear-cache')) {
                $command = $this->getApplication()->find('cache:clear');
                $inputArray = new ArrayInput(array('command' => 'cache:clear'));
                $command->run($inputArray, $output);
            }
        }

        $this->writeln("\nExecuted $executed migrations, failed $failed, skipped $skipped" . ($missed ? ", missed $missed" : ''));

        $time = microtime(true) - $start;
        if ($input->getOption('separate-process')) {
            // in case of using subprocesses, we can not measure max memory used
            $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs</info>");
        } else {
            $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB</info>');
        }

        return $failed;
    }
647715
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $name = $input->getArgument('name');
    $class = implode('', array_map('ucfirst', explode('_', str_replace(':', '_', $name))));

    if ($this->add($name, $class)) {
      return $output->writeln('<info>Command "' . $class . '" has been successfully created.</info>');
    }

    return $output->writeln('Command "' . $class . '" already exists.');
  }
1090741
protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::execute($input, $output);
        $info = $this
            ->getSession()
            ->getInspector()
            ->getSchemas()
            ;
        $this->formatOutput($output, $info);
    }
1372739
protected function waitForUserInput(InputInterface $input, OutputInterface $output)
    {
        $helper   = $this->getHelper('question');
        $question = new Question('<info>You > </info>');

        $message = $helper->ask($input, $output, $question);

        $this->listenForConsoleCommands($input, $output, $message);

        $this->getBotResponse($input, $output, $message);
    }
123531
protected function setIo(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;

        return $this;
    }
326693
final public function console(InputInterface $input)
    {
        if (!$input) {
            $input = new ArgvInput();
        }
        $application = new Application($this);
        return $application->run($input);
    }
218661
public function execute(InputInterface $input): OutputInterface
    {
        $this->validator->validateInput($this, $input);
        $output = $this->generateOutput($input);
        $this->validator->validateOutput($this, $output);
        return $output;
    }
167902
protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::execute($input, $output);

        //$this->runCacheClear(false);
        //$this->runDoctrineMigrate();
        $this->runDoctrineSchemaUpdate();
        $this->runUpdateRoutes();
        $this->runCreateSnapshots();
        //$this->runDoctrineFixturesLoadAppend();
        $this->runCommand('compo:notification:load');
        $this->runCommand('compo:seo:page:load');

        //
        //$this->runCacheWarmup();

        return null;
    }
869287
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);
        $plugins = $this
            ->pluginRepository
            ->findAll();

        /**
         * @var Plugin $plugin
         */
        foreach ($plugins as $plugin) {
            $this->printMessage(
                $output,
                'Plugin',
                $plugin->getNamespace() . ' - [Hash : ' . $plugin->getHash() . ']'
            );
        }

        $this->finishCommand($output);
    }
1186797
public function initialize(InputInterface $input, OutputInterface $output)
    {
        $this->in  = $input;
        $this->out = $output;
    }
166890
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $serverHelper = new DetermineServer();

        $from = $input->getArgument('from');
        $to = $input->getArgument('to');
        $delete = $input->getArgument('delete');


        $fromServer = $serverHelper->getServerForCommand($from);
        $fromPath = $serverHelper->getPathForCommand($from);
        $toServer = $serverHelper->getServerForCommand($to);
        $toPath = $serverHelper->getPathForCommand($to);

        if(!$toServer) {
            $output->writeln('<error>No target...well that was retard.</error>');
            return 500;
        }

        $output->writeln('<comment>Sync Fileadmin from'.$from.' to '.$to.'.</comment>');

        if($delete == 'delete'){
            if (strpos($from, '@') === 0) {
                exec('ssh -A ' . $fromServer . ' rsync -chavzP --delete --stats --exclude=_processed_ --exclude=_temp_ --exclude=log --exclude=sys '.$fromPath.'fileadmin/ '.$toServer . ':' . $toPath . 'fileadmin/');
            } else {
                exec('rsync -chavzP --delete --stats --exclude=_processed_ --exclude=_temp_ --exclude=log --exclude=sys '.$fromPath.'fileadmin/ '.$toServer . ':' . $toPath . 'fileadmin/');
            }
        }else {
            if (strpos($from, '@') === 0) {
                exec('ssh -A ' . $fromServer . ' rsync -chavzP  --stats --exclude=_processed_ --exclude=_temp_ --exclude=log --exclude=sys '.$fromPath.'fileadmin/ '.$toServer . ':' . $toPath . 'fileadmin/');
            } else {
                exec('rsync -chavzP  --stats --exclude=_processed_ --exclude=_temp_ --exclude=log --exclude=sys '.$fromPath.'fileadmin/ '.$toServer . ':' . $toPath . 'fileadmin/');
            }
        }
        return 0;
    }
672107
private function determineStartState(InputInterface $input, string $state_name = null): StateInterface
    {
        if (!$state_name) {
            return $this->getInitialState();
        }
        if (!$this->states->has($state_name)) {
            throw new ExecutionError("Trying to start statemachine execution at unknown state: ".$state_name);
        }
        $start_state = $this->states->get($state_name);
        if ($start_state->isFinal()) {
            throw new ExecutionError("Trying to (re)execute statemachine at final state: ".$state_name);
        }
        if ($start_state->isInteractive() && !$input->hasEvent()) {
            throw new ExecutionError("Trying to resume statemachine executing without providing an event/signal.");
        }
        return $start_state->isInteractive()
            ? $this->activateTransition($input, Output::fromInput($start_state->getName(), $input))
            : $start_state;
    }