当前位置: 首页>>代码示例>>PHP>>正文


PHP Question::getPrompt方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Question\Question::getPrompt方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::getPrompt方法的具体用法?PHP Question::getPrompt怎么用?PHP Question::getPrompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Question\Question的用法示例。


在下文中一共展示了Question::getPrompt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: backportWritePrompt

 /**
  * Outputs the question prompt.
  *
  * Backport from Symfony 2.7
  *
  * @param OutputInterface $output
  * @param Question $question
  *
  * @since 1.1.0 2015-05-22
  */
 protected function backportWritePrompt(OutputInterface $output, Question $question)
 {
     $message = $question->getQuestion();
     if ($question instanceof ChoiceQuestion) {
         $width = max(array_map('strlen', array_keys($question->getChoices())));
         $messages = (array) $question->getQuestion();
         foreach ($question->getChoices() as $key => $value) {
             $messages[] = sprintf("  [<info>%-{$width}s</info>] %s", $key, $value);
         }
         $output->writeln($messages);
         $message = $question->getPrompt();
     }
     $output->write($message);
 }
开发者ID:ofbeaton,项目名称:console-tester,代码行数:24,代码来源:QuestionHelperMock.php

示例2: doAsk

 /**
  * Asks the question to the user.
  *
  * This method is public for PHP 5.3 compatibility, it should be private.
  *
  * @param OutputInterface $output
  * @param Question        $question
  *
  * @return bool|mixed|null|string
  *
  * @throws \Exception
  * @throws \RuntimeException
  */
 public function doAsk(OutputInterface $output, Question $question)
 {
     $inputStream = $this->inputStream ?: STDIN;
     $message = $question->getQuestion();
     if ($question instanceof ChoiceQuestion) {
         $width = max(array_map('strlen', array_keys($question->getChoices())));
         $messages = (array) $question->getQuestion();
         foreach ($question->getChoices() as $key => $value) {
             $messages[] = sprintf("  [<info>%-{$width}s</info>] %s", $key, $value);
         }
         $output->writeln($messages);
         $message = $question->getPrompt();
     }
     $output->write($message);
     $autocomplete = $question->getAutocompleterValues();
     if (null === $autocomplete || !$this->hasSttyAvailable()) {
         $ret = false;
         if ($question->isHidden()) {
             try {
                 $ret = trim($this->getHiddenResponse($output, $inputStream));
             } catch (\RuntimeException $e) {
                 if (!$question->isHiddenFallback()) {
                     throw $e;
                 }
             }
         }
         if (false === $ret) {
             $ret = fgets($inputStream, 4096);
             if (false === $ret) {
                 throw new \RuntimeException('Aborted');
             }
             $ret = trim($ret);
         }
     } else {
         $ret = trim($this->autocomplete($output, $question, $inputStream));
     }
     $ret = strlen($ret) > 0 ? $ret : $question->getDefault();
     if ($normalizer = $question->getNormalizer()) {
         return $normalizer($ret);
     }
     return $ret;
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:55,代码来源:QuestionHelper.php

示例3: writePrompt

 /**
  * Outputs the question prompt.
  *
  * @param OutputInterface $output
  * @param Question        $question
  */
 protected function writePrompt(OutputInterface $output, Question $question)
 {
     $message = $question->getQuestion();
     if ($question instanceof ChoiceQuestion) {
         $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
         $messages = (array) $question->getQuestion();
         foreach ($question->getChoices() as $key => $value) {
             $width = $maxWidth - $this->strlen($key);
             $messages[] = '  [<info>' . $key . str_repeat(' ', $width) . '</info>] ' . $value;
         }
         $output->writeln($messages);
         $message = $question->getPrompt();
     }
     $output->write($message);
 }
开发者ID:unexge,项目名称:symfony,代码行数:21,代码来源:QuestionHelper.php


注:本文中的Symfony\Component\Console\Question\Question::getPrompt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。