SensioLabs\Melody\Console\Command\RunCommand::confirmTrust PHP Method

confirmTrust() private method

private confirmTrust ( SensioLabs\Melody\Resource\Resource $resource, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$resource SensioLabs\Melody\Resource\Resource
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    private function confirmTrust(Resource $resource, InputInterface $input, OutputInterface $output)
    {
        $message = <<<EOT
<comment>You are running an untrusted resource</comment>
  <info>URL:            </info> %s
  <info>Revision:       </info> #%d
  <info>Owner:          </info> %s
  <info>Created at:     </info> %s
  <info>Last update:    </info> %s

EOT;
        $output->writeln(sprintf($message, $resource->getMetadata()->getUri(), $resource->getMetadata()->getRevision(), $resource->getMetadata()->getOwner(), $resource->getMetadata()->getCreatedAt()->format(\DateTime::RSS), $resource->getMetadata()->getUpdatedAt()->format(\DateTime::RSS)));
        $actions = array('abort', 'continue', 'show-code');
        $defaultAction = 'abort';
        $actionLabels = array_map(function ($action) use($defaultAction) {
            if ($action === $defaultAction) {
                return sprintf('<%1$s>%2$s</%1$s>', 'default', $action);
            }
            return $action;
        }, $actions);
        $defaultStyle = clone $output->getFormatter()->getStyle('question');
        $defaultStyle->setOptions(array('reverse'));
        $output->getFormatter()->setStyle('default', $defaultStyle);
        $question = new Question(sprintf('<question>What do you want to do (%s)?</question> ', implode(', ', $actionLabels)), $defaultAction);
        $question->setAutocompleterValues($actions);
        $action = $this->getHelper('question')->ask($input, $output, $question);
        if ($action === 'show-code') {
            $output->writeln(PHP_EOL . $resource->getContent() . PHP_EOL);
            $question = new ConfirmationQuestion('Do you want to continue [y/N]?</question> ', false);
            return $this->getHelper('question')->ask($input, $output, $question);
        }
        return $action === 'continue';
    }