Executes the Drop command.

@param InputInterface $input
@param OutputInterface $output
@param SchemaTool $schemaTool
@param ClassMetadata[] $metadata
@param SymfonyStyle $ui

@return int|NULL 0 or NULL if everything went fine, or an error code
12249
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output,
		SchemaTool $schemaTool, array $metadata, SymfonyStyle $ui)
	{
		$merger = new MetadataMerger();
		$metadata = $merger->merge($metadata);

		return parent::executeSchemaCommand($input, $output, $schemaTool, $metadata, $ui);
	}
957377
protected function dropIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('drop')) {
            return true;
        }

        if (!$input->getOption('no-interaction')) {
            $output->writeln(
                '<comment>ATTENTION</comment>: This operation drops and recreates the whole index and deletes the complete data.'
            );
            $output->writeln('');

            $question = new ConfirmationQuestion('Are you sure you want to drop the index? [Y/n] ');

            /** @var QuestionHelper $questionHelper */
            $questionHelper = $this->getHelper('question');
            if (!$questionHelper->ask($input, $output, $question)) {
                return false;
            }

            $output->writeln('');
        }

        $indexer->dropIndex();

        $context = $this->getContainer()->getParameter('sulu.context');
        $output->writeln(
            sprintf('Dropped and recreated index for the <comment>`%s`</comment> context' . PHP_EOL, $context)
        );

        return true;
    }
32411
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->init($input, $output);

        $this->force_prompt();
                
        $this->publish_packages($this->get_packages());
        
        // Feedback how many files were copied.
        if (\count($this->copied)) {
            $this->output->writeln(
                \sprintf(
                    "\n<info>Published %d %s successfully:\n%s</info>",
                    \count($this->copied),
                    _n('file', 'files', \count($this->copied)),
                    \implode($this->copied, "\n")
                )
            );
            exit;
        }
        
        $this->output->writeln("\n<info>Nothing needed to be published</info>");
    }
376279
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name = $input->getArgument('name');

        $cpath = app_path().'/controllers/';
        $filename = $name.'.php';
        $filepath = $cpath.$filename;

        if (file_exists($filepath)) {
            unlink($filepath);
            $output->writeln("<info>Controller: $name was deleted</info>");

            shell_exec('composer dump-autoload -o');
        } else {
            $output->writeln("<error>Controller: $name doesn't exists!");
        }
    }
102157
public function run(InputInterface $input, OutputInterface $output): ?int
    {
        $return = $this->execute($input, $output);
        if (null === $return) {
            $return = EdgarCronRepository::STATUS_OK;
        }

        return $return;
    }
666264
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $remote = $input->getOption('remote');

        $persistence = $this->getPersistence();

        if (null === $remote) {
            $dialog = $this->getHelper('dialog');

            $remote = $dialog->ask($output, 'Please enter a Git remote to clone and pull from and to push to: ');

            if (!$dialog->askConfirmation($output, '<question>'.$remote.' will be cloned into '.$persistence->getDirectoryName().'. Continue? [y] </question>', false)) {
                $output->writeln('Not cloning, cancelled.');

                return;
            }
        }

        $output->writeln('Cloning...');
        $persistence->cloneRepository($remote);

        $output->writeln(sprintf('Init of git repository for remote "%s" in %s successful', $remote, $persistence->getDirectoryName()));
    }
289977
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (null === $this->configurationChain) {
            $this->configurationChain = $this->getContainer()->get('kunstmaan_search.search_configuration_chain');
        }
        /**
         * @var string
         * @var SearchConfigurationInterface $searchConfiguration
         */
        foreach ($this->configurationChain->getConfigurations() as $alias => $searchConfiguration) {
            $searchConfiguration->deleteIndex();
            $output->writeln('Index deleted : ' . $alias);
        }
    }
1338476
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);
        $style = new SymfonyStyle($input, $output);
        $style->setDecorated(true);
        $style->title($this->description);

        $util = new Util();
        $cbf = $util->checkBinary('phpcbf');
        $output->writeln($util->checkVersion($cbf));
        $source = $util->checkSource($input);
        if ($input->getOption('diff')) {
            $source = $util->getDiffSource();
        }

        if (empty($source)) {
            $output->writeln('<error>No files found</>');
            $style->newLine();

            return 1;
        }

        $cmd = $cbf.' --standard='.$input->getOption('standard').' '.$source;
        $output->writeln('<info>Command: '.$cmd.'</>');
        $style->newLine();
        $process = new Process($cmd);
        $exitCode = $process->setTimeout(3600)->run();

        $changes = true;
        if (strpos($process->getOutput(), 'No fixable errors were found') !== false) {
            $changes = false;
            $output->writeln('<info>No changes</>');
            $style->newLine();

            return 0;
        }

        $changed = $util->getDiffSource();
        if ($changes && !empty($changed)) {
            $output->writeln(str_replace(' ', PHP_EOL, $changed));
            $sources = explode(' ', $changed);
            $style->newLine();

            foreach ($sources as $source) {
                $git = 'git -c color.ui=always';
                $options = '--compaction-heuristic -U0 --patch --minimal --patience';
                $process = new Process($git.' diff '.$options.' '.$source);
                $process->run();
                $output->writeln($process->getOutput());
            }
        }

        $end = microtime(true);
        $time = round($end - $start);

        $style->section('Results');
        $output->writeln('<info>Time: '.$time.' seconds</>');
        $style->newLine();

        return $exitCode;
    }
18427
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $searchDir = ModulusCLI::$appdir . 'storage' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR;

    $logs = glob($searchDir . '*.log');

    if (count($logs) < 1) {
      return $output->writeln('Nothing to remove');
    }

    foreach($logs as $log) {
      try {
        Filesystem::delete($log);
      } catch (\Exception $e) {
        return $output->writeln($e->getMessage());
      }
    }

    return $output->writeln('<info>Cleared logs</info>');
  }
588099
public function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('stop-on-failure')) {
            return null;
        }

        if ($input->getOption('strict')) {
            $this->resultInterpretation = new StrictInterpretation();
        }

        $this->eventDispatcher->addListener(ScenarioTested::AFTER, array($this, 'exitOnFailure'), -100);
        $this->eventDispatcher->addListener(ExampleTested::AFTER, array($this, 'exitOnFailure'), -100);
    }
1070850
protected function execute(InputInterface $input, OutputInterface $output) : ?int
    {
        $loggerHelper = new LoggerHelper();
        $logger       = $loggerHelper->create($output);

        /** @var string $resources */
        $resources = $input->getOption('resources');

        $divisionsResourcePath = $resources . '/user-agents';

        $logger->info('Resource folder: ' . $resources);

        $schemaStorage   = new SchemaStorage();
        $schemaValidator = new Validator\SchemaValidator(
            new \JsonSchema\Validator(
                new Constraints\Factory(
                    $schemaStorage,
                    $schemaStorage->getUriRetriever()
                )
            )
        );

        $schemaUri = 'file://' . realpath(__DIR__ . '/../../../schema/divisions.json');

        try {
            /** @var \stdClass $schema */
            $schema = $schemaStorage->getSchema($schemaUri);
        } catch (\Throwable $exception) {
            $logger->critical('the schema file is invalid');

            return 1;
        }
        $failed = false;

        $jsonParser = new JsonParser();

        $finder = new Finder();
        $finder->files();
        $finder->name('*.json');
        $finder->ignoreDotFiles(true);
        $finder->ignoreVCS(true);
        $finder->sortByName();
        $finder->ignoreUnreadableDirs();
        $finder->in($divisionsResourcePath);

        foreach ($finder as $file) {
            /* @var \Symfony\Component\Finder\SplFileInfo $file */
            $logger->info('read source file ' . $file->getPathname());

            try {
                $json = $file->getContents();
            } catch (\RuntimeException $e) {
                $logger->critical(new \Exception(sprintf('could not read file "%s"', $file->getPathname()), 0, $e));

                continue;
            }

            try {
                $decoded = $jsonParser->parse($json, JsonParser::DETECT_KEY_CONFLICTS);

                if (!$schemaValidator->isValid($decoded, $schema)) {
                    $logger->critical(sprintf('file "%s" is not valid', $file->getPathname()));
                    $failed = true;
                }
            } catch (ParsingException $e) {
                $logger->critical('File "' . $file->getPathname() . '" had invalid JSON. [JSON error: ' . json_last_error_msg() . ']');
                $failed = true;
            }
        }

        if (!$failed) {
            $output->writeln('the division files are valid');
        }

        return (int) $failed;
    }
1254122
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');

        $io = new SymfonyStyle($input, $output);
        $io->title('EventSearch Storage Creator');
        $io->comment(sprintf('context: %s', json_encode($context)));

        $this->getPbjx()->getEventSearch()->createStorage($context);
        $io->success(sprintf('EventSearch storage created.'));
    }
1303419
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $filename = $input->getArgument('filename');
        $key = $input->getArgument('key');
        $yaml_parsed = $this->loadYamlFile($filename);
        if (!$yaml_parsed) {
            // Exit with a status of 1.
            return 1;
        }

        $data = new Data($yaml_parsed);
        if (!$this->checkKeyExists($data, $key)) {
            return 1;
        }

        $data->remove($key);

        if ($this->writeYamlFile($filename, $data)) {
            $this->output->writeln("<info>The key '$key' was removed from $filename.</info>");
        }
    }
140100
private function dumpMetadata(array $metadata, InputInterface $input, OutputInterface $output)
    {
        foreach ($metadata as $name => $meta) {
            $output->writeln(sprintf('<info>%s</info>', $name));

            foreach ($meta['fields'] as $fieldName => $columnName) {
                $output->writeln(sprintf('  <comment>></comment> %s <info>=></info> %s', $fieldName, $columnName));
            }
        }
        $output->writeln('---------------');
        $output->writeln('----  END  ----');
        $output->writeln('---------------');
        $output->writeln('');

        if ($input->getOption('filename')) {
            $directory = \dirname($input->getOption('filename'));
            $filename = basename($input->getOption('filename'));

            if (empty($directory) || '.' === $directory) {
                $directory = getcwd();
            }

            $adapter = new LocalAdapter($directory, true);
            $fileSystem = new Filesystem($adapter);
            $success = $fileSystem->write($filename, json_encode($metadata), true);

            if ($success) {
                $output->writeLn(sprintf('<info>File %s/%s successfully created</info>', $directory, $filename));
            } else {
                $output->writeLn(sprintf('<error>File %s/%s could not be created</error>', $directory, $filename));
            }
        }
    }
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;
    }
534714
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->getHelper('phpdocumentor_logger')->connectOutputToLogging($output, $this);

        $converter = $this->getConverter($input);
        $converter->setOption('title', $input->getOption('title'));

        $output->writeln('Collect all documents');
        $files = $this->buildCollection(
            $input->getArgument('source'),
            $converter->getDefinition()->getInputFormat()->getExtensions()
        );

        $output->writeln('Converting documents');
        $files = $converter->convert($files, $this->getTemplate($input));

        $output->writeln('Writing converted documents to disk');
        $this->writeToDisk($files, $input->getOption('target'));

        $output->writeln('Writing assets to disk');
        $converter->getAssets()->copyTo($input->getOption('target'));
    }
1188387
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;
        $io = new SymfonyStyle($input, $output);

        $config = $this->getConfigHelper()->load($input);
        $typeMap = TypeMap::fromMetadata(
            $config->getTypeNamespace(),
            $config->getEngine()->getMetadata()->getTypes()
        );

        $generator = new ClassMapGenerator(
            $config->getRuleSet(),
            $config->getClassMapName(),
            $config->getClassMapNamespace()
        );
        $path = $config->getClassMapDestination().DIRECTORY_SEPARATOR.$config->getClassMapName().'.php';
        $this->handleClassmap($generator, $typeMap, $path);

        $io->success('Generated classmap at ' . $path);
    }