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

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

protected validateInput ( Symfony\Component\Console\Input\InputInterface $input, boolean $envNotRequired = false )
$input Symfony\Component\Console\Input\InputInterface
$envNotRequired boolean
    protected function validateInput(InputInterface $input, $envNotRequired = false)
    {
        $projectId = $input->hasOption('project') ? $input->getOption('project') : null;
        $projectHost = $input->hasOption('host') ? $input->getOption('host') : null;
        $environmentId = null;
        // Parse the project ID.
        if ($projectId !== null) {
            $result = $this->parseProjectId($projectId);
            $projectId = $result['projectId'];
            $projectHost = $projectHost ?: $result['host'];
            $environmentId = $result['environmentId'];
        }
        // Set the --app option based on the parsed project URL, if relevant.
        if (isset($result['appId']) && $input->hasOption('app') && !$input->getOption('app')) {
            $input->setOption('app', $result['appId']);
        }
        // Select the project.
        $this->project = $this->selectProject($projectId, $projectHost);
        // Select the environment.
        $envOptionName = 'environment';
        if ($input->hasArgument($this->envArgName) && $input->getArgument($this->envArgName)) {
            if ($input->hasOption($envOptionName) && $input->getOption($envOptionName)) {
                throw new \InvalidArgumentException(sprintf('You cannot use both the <%s> argument and the --%s option', $this->envArgName, $envOptionName));
            }
            $argument = $input->getArgument($this->envArgName);
            if (is_array($argument) && count($argument) == 1) {
                $argument = $argument[0];
            }
            if (!is_array($argument)) {
                $this->debug('Selecting environment based on input argument');
                $this->environment = $this->selectEnvironment($argument);
            }
        } elseif ($input->hasOption($envOptionName)) {
            $environmentId = $input->getOption($envOptionName) ?: $environmentId;
            if (!$environmentId && $envNotRequired) {
                $this->environment = $this->getCurrentEnvironment($this->project);
            } else {
                $this->environment = $this->selectEnvironment($environmentId);
            }
        }
        $this->debug('Validated input');
    }