Platformsh\Cli\Command\CommandBase::selectApp PHP Метод

selectApp() защищенный Метод

Find the name of the app the user wants to use for an SSH command.
protected selectApp ( Symfony\Component\Console\Input\InputInterface $input, callable $filter = null ) : string | null
$input Symfony\Component\Console\Input\InputInterface The user input object.
$filter callable A filter callback that takes one argument: a LocalApplication object.
Результат string | null The application name, or null if it could not be found.
    protected function selectApp(InputInterface $input, callable $filter = null)
    {
        $appName = $input->getOption('app');
        if ($appName) {
            return $appName;
        }
        $projectRoot = $this->getProjectRoot();
        if (!$projectRoot || !$this->selectedProjectIsCurrent()) {
            return null;
        }
        $this->debug('Searching for applications in local repository');
        /** @var LocalApplication[] $apps */
        $apps = LocalApplication::getApplications($projectRoot, self::$config);
        if ($filter) {
            $apps = array_filter($apps, $filter);
        }
        if (count($apps) > 1 && $input->isInteractive()) {
            /** @var \Platformsh\Cli\Helper\QuestionHelper $questionHelper */
            $questionHelper = $this->getHelper('question');
            $choices = [];
            foreach ($apps as $app) {
                $choices[$app->getName()] = $app->getName();
            }
            $appName = $questionHelper->choose($choices, 'Enter a number to choose an app:');
        }
        $input->setOption('app', $appName);
        return $appName;
    }