AcmePhp\Cli\Command\AuthorizeCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $client = $this->getClient();
        $domain = $input->getArgument('domain');
        $solverName = strtolower($input->getOption('solver'));
        /** @var SolverLocator $solverLocator */
        $solverLocator = $this->getContainer()->get('challenge_solver.locator');
        if (!$solverLocator->hasSolver($solverName)) {
            throw new \UnexpectedValueException(sprintf('The solver "%s" does not exists. Available solvers are: (%s)', $solverName, implode(', ', $solverLocator->getSolversName())));
        }
        /** @var SolverInterface $solver */
        $solver = $solverLocator->getSolver($solverName);
        $output->writeln(sprintf('<info>Requesting an authorization token for domain %s ...</info>', $domain));
        $authorizationChallenges = $client->requestAuthorization($domain);
        $authorizationChallenge = null;
        foreach ($authorizationChallenges as $candidate) {
            if ($solver->supports($candidate)) {
                $authorizationChallenge = $candidate;
                break;
            }
        }
        if (null === $authorizationChallenge) {
            throw new ChallengeNotSupportedException();
        }
        $this->getRepository()->storeDomainAuthorizationChallenge($domain, $authorizationChallenge);
        $this->output->writeln('<info>The authorization token was successfully fetched!</info>');
        $solver->solve($authorizationChallenge);
        $this->output->writeln(sprintf(<<<'EOF'
<info>Then, you can ask to the CA to check the challenge!</info>
    Call the <info>check</info> command to ask the server to check your URL:

    php <info>%s check</info> -s %s %s

EOF
, $_SERVER['PHP_SELF'], $solverName, $domain));
    }
AuthorizeCommand