Check argument sites and set $this->sites

@param InputInterface $input
509850
protected function setSites(InputInterface $input)
    {
        $sites = SiteTable::query()
            ->setFilter([
                'LID' => $input->getArgument('sites'),
            ])
            ->setSelect(['LID'])
            ->exec();

        if ($sites->getSelectedRowsCount() <= 0) {
            $this->errors[] = 'Sites not found';
        }

        $this->sites = $sites->fetchAll();
    }
229151
private function listAllSites(OutputInterface $output)
    {
        $output->writeln(sprintf(' % 5s - % -30s - %s', 'ID', 'Name', 'Url'));

        $sites = $this->getSiteManager()->findAll();

        foreach ($sites as $site) {
            $output->writeln(sprintf(' % 5s - % -30s - %s', $site->getId(), $site->getName(), $site->getUrl()));
        }
    }
770695
public static function setSites($sites)
    {
        self::triggerSetSitesEvent($sites);

        foreach ($sites as $idsite => $site) {
            self::setSiteFromArray($idsite, $site);
        }
    }
152396
protected function configureOptions(InputInterface $input)
    {
        if ($input->getOption('path')) {
            $this->finder->setPath($input->getOption('path'));
            $this->locator->setParams(array('path' => $input->getOption('path')));
        }
    }
16688
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        // Determine app and environment from path.
        $cwd = getcwd();
        $config = $this->getApplication()->getTerra()->getConfig();

        foreach ($config->get('apps') as $app) {
            if (!isset($app['environments'])) {
              $app['environments'] = array();
            }
            foreach ($app['environments'] as $environment) {
                if (strpos($cwd, $environment['path']) === 0) {
                  
                    if ($input->hasArgument('app_name')) {
                      $input->setArgument('app_name', $app['name']);
                    }
                    
                    if ($input->hasArgument('environment_name')) {
                      $input->setArgument('environment_name', $environment['name']);
                    }

                    $environment_string = $app['name'] . ':' . $environment['name'];

                    $output->writeln("Using environment <question>$environment_string</question>");
                }
            }
        }
    }
405874
protected function ping(InputInterface $input, OutputInterface $output)
    {
        $input;
        //====================================================================//
        // Perform Ping Test
        $result = Splash::Selftest();
        //====================================================================//
        // Output Result
        $output->writeln($result
                ? "<bg=green;fg=white;options=bold>=== SPLASH : PING TEST PASSED </>"
        : "<bg=green;fg=white;options=bold>=== SPLASH : PING TEST PASSED </>");
    }
632971
private function setInputAndOutput(InputInterface $input, OutputInterface $output)
    {
        if (is_null($this->assistant)) {
            $this->assistant = new CommandAssistant();
            $this->assistant->setQuestionHelper($this->getQuestionHelper());
            $this->assistant->setKernel($this->getApplication()->getKernel());
        }
        $this->assistant->setOutput($output);
        $this->assistant->setInput($input);
    }
19439
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $aliasId = $input->getArgument('aliasId');
        $limit = 20;

        $objectManager = $this->getContainer()->get('object_manager');
        $siteClass = $this->getContainer()->getParameter('open_orchestra_model.document.site.class');
        $nodeClass = $this->getContainer()->getParameter('open_orchestra_model.document.node.class');

        $site = $objectManager->getRepository($siteClass)
            ->findOneBy(array(
                'aliases.'.$aliasId => array('$exists' => true)
                )
            );

        if($site instanceof $siteClass) {
            $aliases = $site->getAliases();
            if ($aliases->containsKey($aliasId)) {
                $siteId = $site->getSiteId();
                $language = $aliases[$aliasId]->getLanguage();
                $lastAlias = true;
                foreach ($aliases as $key => $alias) {
                    if ($alias->getLanguage() == $language && $key != $aliasId) {
                        $lastAlias = false;
                    }
                }
            }

            if ($lastAlias) {
                $io->comment('Remove use references of nodes');

                $deleteSiteTools = $this->getContainer()->get('open_orchestra_backoffice.command.orchestra_delete_site_tools');

                $nodes = $objectManager->createQueryBuilder($nodeClass)
                    ->field('siteId')->equals($siteId)
                    ->field('language')->equals($language)
                    ->getQuery()->execute();

                $usedInNodes = $deleteSiteTools->findUsageReferenceInOtherSite($siteId, $nodes);
                if (!empty($usedInNodes)) {
                    $io->section('Usage of nodes in other sites');
                    $deleteSiteTools->displayUsedReferences($io, $usedInNodes);
                    throw new \RuntimeException('You should remove usage of nodes before remove alias ' . $aliasId);
                }

                $count = count($nodes);

                for ($skip = 0; $skip < $count; $skip += $limit) {
                    $nodes = $objectManager->createQueryBuilder($nodeClass)
                        ->field('siteId')->equals($siteId)
                        ->field('language')->equals($language)
                        ->sort('id', 'asc')
                        ->skip($skip)
                        ->limit($limit)
                        ->getQuery()->execute();
                    foreach ($nodes as $node) {
                        $this->getContainer()->get('open_orchestra_backoffice.reference.manager')->removeReferencesToEntity($node);
                    }
                    $objectManager->clear();
                }

                $io->comment('Remove nodes');
                $objectManager->createQueryBuilder($nodeClass)
                    ->field('siteId')->equals($siteId)
                    ->field('language')->equals($language)
                    ->remove()->getQuery()->execute();
            }

            $site->removeAlias($aliases->get($aliasId));
            $objectManager->persist($site);
            $objectManager->flush();

        }
    }
437625
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $siteBuilder = new SiteBuilder(
            $this->filesystem,
            $this->viewFactory,
            $input->getOption('env'),
            $input->getOption('force')
        );

        $siteBuilder->build();

        $output->writeln("<info>Site was generated successfully.</info>");
    }
446181
public function addInput(Input $input)
    {
        $reflection = new \ReflectionClass($input);

        $method = 'add'.$reflection->getShortName();

        if (method_exists($this, $method)) {
            $this->$method(...array_values($input->getAttributes()));
        }
    }
537063
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $themeName = $input->getArgument('theme');
        $kernel = $this->getContainer()->get('kernel');
        $dir = $kernel->locateResource('@' . $themeName);
        $namespace = $kernel
            ->getBundle($themeName)
            ->getNamespace()
        ;

        // @codeCoverageIgnoreStart
        if (null === $this->templateParser) {
            $this->templateParser = new TemplateParser($this->getContainer()->get('templating.locator'), $this->getContainer()->get('templating.name_parser'));
        }

        if (null === $this->templateGenerator) {
            $this->templateGenerator = new TemplateGenerator();
        }

        if (null === $this->slotsGenerator) {
            $this->slotsGenerator = new SlotsGenerator();
        }

        if (null === $this->extensionGenerator) {
            $this->extensionGenerator = new ExtensionGenerator();
        }
        // @codeCoverageIgnoreEnd

        $parsedTemplates = $this->templateParser->parse($dir . 'Resources/views/Theme', $kernel->getRootDir(), $themeName);
        $this->addOption('template-name', '', InputOption::VALUE_NONE, '');
        $templates = $parsedTemplates["templates"];
        foreach ($templates as $templateAttributes) {
            $templateFileName = $templateAttributes["name"];
            $templateName = basename($templateFileName, '.html.twig');
            $message = $this->templateGenerator->generateTemplate($dir . 'Resources/config/templates', $themeName, $templateName, $templateAttributes["slots"]);
            $output->writeln($message);
        }

        $message = $this->slotsGenerator->generateSlots($dir . 'Resources/config/slots', $themeName, $parsedTemplates["slots"]);
        $output->writeln($message);

        $message = $this->extensionGenerator->generateExtension($namespace, $dir . 'DependencyInjection', $themeName, $templates);
        $output->writeln($message);
    }
216255
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->bootstrap($input, $output);

        $environment = $input->getOption('environment');
        $version = $input->getOption('target');
        $removeAll = $input->getOption('remove-all');

        if ($environment === null) {
            $environment = $this->getConfig()->getDefaultEnvironment();
            $output->writeln('<comment>warning</comment> no environment specified, defaulting to: ' . $environment);
        } else {
            $output->writeln('<info>using environment</info> ' . $environment);
        }

        if ($version && $removeAll) {
            throw new \InvalidArgumentException('Cannot toggle a breakpoint and remove all breakpoints at the same time.');
        }

        // Remove all breakpoints
        if ($removeAll) {
            $this->getManager()->removeBreakpoints($environment);
        } else {
            // Toggle the breakpoint.
            $this->getManager()->toggleBreakpoint($environment, $version);
        }
    }
672308
protected function setDir(InputInterface $input)
    {
        $app = new Application();
        $filesystem = new Filesystem();
        $dir = $input->getArgument('dir');

        if (!$dir) {
            $dir = $app->getRoot();
        } elseif (!$filesystem->isAbsolutePath($dir)) {
            $dir = $app->getRoot() . DIRECTORY_SEPARATOR . $dir;
        }
        $dir = rtrim($dir, DIRECTORY_SEPARATOR);

        if (!$filesystem->exists($dir)) {
            $this->errors[] = "Directory $dir not found";
        }

        $this->dir = $dir;
    }
762071
protected function workInForeground(InputInterface $input): void
    {
        $pidfile = $input->getOption('pidfile');
        if ($pidfile) {
            $this->writePidFile($pidfile);
        }

        $worker_factory = $this->worker_factory;

        /** @var array $queues */
        $queues = $input->getArgument('queues');

        /** @var \QueueJitsu\Worker\Worker $worker */
        $worker = $worker_factory($queues);

        $worker($input->getOption('interval'));
    }
354008
protected function workInBackground(InputInterface $input): void
    {
        $worker_count = $input->getOption('workers');

        for ($i = 0; $i < $worker_count; ++$i) {
            $pid = pcntl_fork();

            if ($pid === -1) {
                die(sprintf("Could not fork worker %d\n", $i));
            }

            if (!$pid) {
                $pidfile = $input->getOption('pidfile');
                if ($pidfile && $i === 0) {
                    $this->writePidFile($pidfile);
                }

                $worker_factory = $this->worker_factory;

                /** @var array $queues */
                $queues = $input->getArgument('queues');

                /** @var \QueueJitsu\Worker\Worker $worker */
                $worker = $worker_factory($queues);

                $worker($input->getOption('interval'));
                break;
            }
        }
    }
893976
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Available templates:');
        foreach ($this->factory->getAllNames() as $template_name) {
            $output->writeln('* '.$template_name);
        }
        $output->writeln('');
    }
136960
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $config = new Config(
            $input->getOption('prod'),
            $input->getOption('destination'),
            '/sites/all/modules/%s',
            '/sites/all/themes/%s',
            '/sites/all/drush/%s',
            '/profiles/%s',
            '/sites/default/files',
            '/sites/default/files-private',
            '/sites/default/settings.php'
        );

        $finder = new Finder(
             $input->getOption('source'),
            $input->getOption('destination'),
            'cnf/files',
            'cnf/private',
            'cnf/settings.php'
        );

        $im = $this->getComposer()->getInstallationManager();
        $rm = $this->getComposer()->getRepositoryManager();

        $mapper = new Mapper($config, $finder, $im, $rm);
        $mapper->clear();
        $mapper->mirror($mapper->getMap());
    }