@param InputInterface $input

@return Package[]
345361
private function checkPackagesFlag(InputInterface $input)
    {
        $result = [];
        if (count($input->getOption('packages')) > 0) {
            if (!$this->app->isInstalled()) {
                throw new Exception('concrete5 is not installed: you can only work with core language files.');
            }
            $proceed = true;
        } elseif (!$input->getOption('core')) {
            $proceed = $this->app->isInstalled();
        } else {
            $proceed = false;
        }
        if ($proceed) {
            $pkgList = $input->getOption('packages');
            if ($pkgList === [null]) {
                $pkgList = [];
            }
            $ps = $this->app->make(PackageService::class);
            /* @var PackageService $ps */
            $allPackages = $ps->getAvailablePackages(false);
            if (count($pkgList) === 0) {
                $result = $allPackages;
            } else {
                foreach ($pkgList as $pkg) {
                    $package = null;
                    foreach ($allPackages as $p) {
                        if (strcasecmp($p->getPackageHandle(), $pkg) === 0) {
                            $package = $p;
                            break;
                        }
                    }
                    if ($package === null) {
                        throw new Exception(sprintf('Unable to find a package with handle %s', $pkg));
                    }
                    if (!in_array($package, $result, true)) {
                        $result[] = $package;
                    }
                }
            }
        }

        return $result;
    }
975554
private function getFinalOptions(InputInterface $input)
    {
        $options = $input->getOptions();
        if (isset($options['config']) && $options['config'] && strtolower($options['config']) !== 'none') {
            if (!is_file($options['config'])) {
                throw new Exception('Unable to find the configuration file ' . $options['config']);
            }
            $configOptions = include $options['config'];
            if (!is_array($configOptions)) {
                throw new Exception('The configuration file did not returned an array.');
            }
            foreach ($configOptions as $k => $v) {
                if (!$input->hasParameterOption("--$k")) {
                    $options[$k] = $v;
                }
            }
        }
        if (empty($options['timezone'])) {
            $options['timezone'] = @date_default_timezone_get() ?: 'UTC';
        }
        $options['attach'] = (bool) $input->getOption('attach');
        $options['force_attach'] = (bool) $input->getOption('force-attach');
        $options['auto_attach'] = $options['attach'] || $options['force_attach'];

        return $options;
    }
72678
protected function getConfiguration(InputInterface $input): ConsoleConfigInterface
    {
        // If the configuration to use is the default.
        if ($input->getOption('default')) {
            $this->validatePathsExist($input);
            // If it is a directory.
            if ($input->getOption('dir')) {
                return (new DefaultConsoleConfigFactory())
                    ->invokeDir($input->getArgument('source'), $input->getArgument('target'));
            }
            return (new DefaultConsoleConfigFactory())
                ->invokeFile($input->getArgument('source'), $input->getArgument('target'));
        }

        $path = $input->getOption('config');
        // If we have a "=" at the beginning of the option value
        $path = preg_replace('/^\=/', '', $path);

        $factory = $this->getConfigurationFactory($path);

        if ($input->getOption('dir')) {
            $this->validatePathsExist($input);
            return $factory->invokeDir(
                $path,
                $input->getArgument('source'),
                $input->getArgument('target')
            );
        }
        if ($input->getOption('file')) {
            $this->validatePathsExist($input);
            return $factory->invokeFile(
                $path,
                $input->getArgument('source'),
                $input->getArgument('target')
            );
        }
        return $factory->invoke($path);
    }
1045532
public function createProjectByInput(InputInterface $input) : Project
    {
        $configFinder = new ConfigFinder();
        $configLoader = new ConfigLoader();

        /**
         * This section is just for finding the right values to work with in
         * this execution.
         *
         * $options array will have, after this block, all these values
         */
        $configPath = rtrim($input->getOption('config'), DIRECTORY_SEPARATOR);
        $configValues = $configLoader->loadConfigValues(
            $configFinder->findConfigFile($configPath)
        );

        $masterLanguage = $configValues['master_language'];
        $languages = $configValues['languages'];
        $filePaths = $configValues['paths'];

        return Project::create(
            $masterLanguage,
            $languages,
            $filePaths
        );
    }
1295491
protected function getUsableConfig(InputInterface $input)
    {
        $configLoader = new ConfigLoader();
        $configFinder = new ConfigFinder();

        /**
         * This section is just for finding the right values to work with in
         * this execution.
         *
         * $options array will have, after this block, all these values
         */
        $configPath = rtrim($input->getOption('config'), DIRECTORY_SEPARATOR);

        $configValue = $configLoader->loadConfigValues(
            $this->getCommandConfigAlias(),
            $configFinder->findConfigFile($configPath),
            $this->getCommandConfigValue($input),
            $this->getDefaultConfigValue()

        );

        if (is_null($configValue)) {
            throw new Exception("Config definition must be defined in .formatter.yml file under {$this->getCommandConfigAlias()}");
        }

        return $configValue;
    }
610372
protected function getStrategyOption(InputInterface $input)
    {
        $strategy = strtolower($input->getOption(MigrateMessage::OPT_STRATEGY));
        if (!isset($this->strategies[$strategy])) {
            throw new CliException(sprintf(
                'Unknown strategy "%s". Must be one of: %s',
                $strategy,
                implode(', ', array_keys($this->strategies))
            ));
        }

        return $this->strategies[$strategy];
    }
1236433
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $packages = explode(',', $input->getArgument('package'));
        $type = $input->getOption('type');

        foreach ($packages as $package) {
            $output->writeln('### Orchestrator::installComposerPackage() for '.$package.' and type: '.$type.'  ###');
            Orchestrator::installComposerPackage($package, $type);
        }
    }
736776
protected function repoName(InputInterface $input) {
        $name = $input->getArgument('name');
        return isset($name) ? $name : basename(getcwd());
    }
819208
protected function setup(InputInterface $input)
    {
        return $this->setup
            ->setForcedRollback($input->getOption('force-rollback'))
            ->setExecuteQueries($input->getOption('execute'))
            ->setRollbackedFirst($input->getOption('rollback-first'))
            ->run();
    }
1041112
protected function getSites(InputInterface $input)
    {
        $parameters = [];
        $identifiers = $input->getOption('site');

        if ('all' !== current($identifiers)) {
            $parameters['id'] = 1 === \count($identifiers) ? current($identifiers) : $identifiers;
        }

        return $this->getSiteManager()->findBy($parameters);
    }
898208
public function getFileList( PackageInterface $package, $map ) {
    $directory = $this->getDirectory( $package );
    $result    = [];

    try {

      foreach( $map as $source => $destination ) {
        if( !is_dir( $directory . $source ) ) $result[ $directory . $source ] = Autoload::DIRECTORY . $destination;
        else {

          $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator( $directory . $source, \RecursiveDirectoryIterator::SKIP_DOTS ),
            \RecursiveIteratorIterator::SELF_FIRST
          );

          foreach( $iterator as $item ) {
            /** @var SplFileInfo $item */
            if( !$item->isDir() ) {
              $result[ $item->getRealPath() ] = Autoload::DIRECTORY . $destination . DIRECTORY_SEPARATOR . call_user_func( [ $iterator, 'getSubPathName' ] );
            }
          }
        }
      }

    } catch( \Throwable $e ) {
      $this->io->writeError( "Spoom\\Composer: Skip {$package->getPrettyName()} public copy, due to an error" );
    }

    return $result;
  }
1060578
protected function targetDirectory(InputInterface $input)
    {
        $pid = $input->getParameterOption(['--path', '-p']);

        if (empty($pid)) {
            $path = app()->getPath().'/runtime/process';
        } else {
            $path = dirname($pid);
        }
        if (!file_exists($path)) {
            mkdir($path, 0755, true);
        }

        return $this->pidPath = $path;
    }
826199
protected function getConfiguration(InputInterface $input)
    {
        $configuration = new Configuration();

        $configuration->setImagine($this->getImagine($input->getOption('driver')));
        $configuration->setOptions($input->getOption('options'));

        $configuration->getFinder()
               ->name($input->getArgument('pattern'))
               ->in($input->getArgument('source'));

        $configuration->setImage($input->getArgument('image'));
        $configuration->setColor(new Color($input->getOption('color'), $input->getOption('alpha')));
        $configuration->setStylesheet($input->getArgument('stylesheet'));
        $configuration->setSelector($input->getArgument('selector'));

        return $configuration;
    }
1278022
private function getUpdateData(InputInterface $input)
    {
        $update_data = $input->getOption('update-data');

        if (empty($update_data)) {
            return null;
        }

        if (mb_substr($update_data, 0, 1) == '{' && mb_substr($update_data, mb_strlen($update_data) - 1) == '}') {
            $update_data = json_decode($update_data, true);

            if (json_last_error()) {
                $error_message = 'Failed to parse JSON';

                if (function_exists('json_last_error_msg')) {
                    $error_message .= '. Reason: ' . json_last_error_msg();
                }

                throw new InvalidArgumentException('Failed to parse updata data value. Error: ' . $error_message);
            }

            return $update_data;
        } else {
            throw new InvalidArgumentException("Invalid JSON: '$update_data'");
        }
    }
843444
private function fromFlattenedSerializationRecipientToSerialization($input)
    {
        $recipient = [];
        foreach (['header', 'encrypted_key'] as $key) {
            if (array_key_exists($key, $input)) {
                $recipient[$key] = $input[$key];
            }
        }
        $recipients = [
            'ciphertext' => $input['ciphertext'],
            'recipients' => [$recipient],
        ];
        foreach (['protected', 'unprotected', 'iv', 'aad', 'tag'] as $key) {
            if (array_key_exists($key, $input)) {
                $recipients[$key] = $input[$key];
            }
        }

        $this->log(LogLevel::INFO, 'JWE in Flattened JSON Serialization mode loaded.');

        return $recipients;
    }
1356724
private function getSelectContainer(EnvironmentInterface $environment)
    {
        $inputProvider  = $environment->getInputProvider();
        $sessionStorage = $environment->getSessionStorage();

        $sessionName = $environment->getDataDefinition()->getName() . '.' . $inputProvider->getParameter('mode');
        if (!$sessionStorage->has($sessionName)) {
            return [];
        }

        $selectAction = $inputProvider->getParameter('select');
        if (!$selectAction) {
            return [];
        }

        $session = $sessionStorage->get($sessionName);
        if (!\array_key_exists($selectAction, $session)) {
            return [];
        }

        return $session[$selectAction];
    }
1164180
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $packages = $this->getPackages($input->getArgument('vendors'));

        $table = $this->getTable($output);

        foreach ($packages as $package) {
            $table->addRow([
                $package->getName(),
                $package->getDownloads()->getTotal(),
                $package->getDownloads()->getMonthly(),
            ]);
        }

        $table->addRow(new TableSeparator());

        $table->addRow(['SUMMARY', $packages->getAllTimeTotal(), $packages->getMonthlyTotal()]);

        $table->render();
    }