Gush\Adapter\DefaultConfigurator::interact PHP Méthode

interact() public méthode

public interact ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    public function interact(InputInterface $input, OutputInterface $output)
    {
        $config = [];
        if (count($this->authenticationOptions) > 1) {
            $authenticationLabels = array_map(function ($value) {
                return ucfirst($value[0]);
            }, $this->authenticationOptions);
            $authenticationType = array_search($this->questionHelper->ask($input, $output, new ChoiceQuestion('Choose ' . $this->label . ' authentication type:', $authenticationLabels, $authenticationLabels[0])), $authenticationLabels, true);
        } else {
            $authenticationType = 0;
            $authenticationLabels = [$this->authenticationOptions[0][0]];
        }
        $config['authentication'] = [];
        $config['authentication']['http-auth-type'] = $this->authenticationOptions[$authenticationType][1];
        $config['authentication']['username'] = $this->questionHelper->ask($input, $output, (new Question('Username: '))->setValidator([$this, 'validateNoneEmpty']));
        $config['authentication']['password-or-token'] = $this->questionHelper->ask($input, $output, (new Question($authenticationLabels[$authenticationType] . ': '))->setValidator([$this, 'validateNoneEmpty'])->setHidden(true));
        $config['base_url'] = $this->questionHelper->ask($input, $output, (new Question(sprintf('Enter your %s api url [%s]: ', $this->label, $this->apiUrl), $this->apiUrl))->setValidator([$this, 'validateUrl']));
        $config['repo_domain_url'] = $this->questionHelper->ask($input, $output, (new Question(sprintf('Enter your %s repo url [%s]: ', $this->label, $this->repoUrl), $this->repoUrl))->setValidator([$this, 'validateUrl']));
        return $config;
    }

Usage Example

 public function interact(InputInterface $input, OutputInterface $output)
 {
     $config = parent::interact($input, $output);
     $config['base_url'] = rtrim($config['base_url'], '/');
     $config['repo_domain_url'] = rtrim($config['repo_domain_url'], '/');
     return $config;
 }
All Usage Examples Of Gush\Adapter\DefaultConfigurator::interact