Exemplo n.º 1
0
Arquivo: Output.php Projeto: liip/rmt
 public function askQuestion(InteractiveQuestion $question, $position = null, InputInterface $input = null)
 {
     $text = ($position !== null ? $position . ') ' : null) . $question->getFormatedText();
     if ($this->dialogHelper instanceof QuestionHelper) {
         if (!$input) {
             throw new \InvalidArgumentException('With symfony 3, the input stream may not be null');
         }
         $q = new Question($text, $question->getDefault());
         $q->setValidator($question->getValidator());
         if ($question->isHiddenAnswer()) {
             $q->setHidden(true);
         }
         return $this->dialogHelper->ask($input, $this, $q);
     }
     if ($this->dialogHelper instanceof DialogHelper) {
         if ($question->isHiddenAnswer()) {
             return $this->dialogHelper->askHiddenResponseAndValidate($this, $text, $question->getValidator(), false);
         }
         return $this->dialogHelper->askAndValidate($this, $text, $question->getValidator(), false, $question->getDefault());
     }
     throw new \RuntimeException("Invalid dialogHelper");
 }
Exemplo n.º 2
0
 protected function askQuestion(InteractiveQuestion $question)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     return $dialog->askAndValidate($this->getOutput(), $question->getFormatedText(), $question->getValidator(), false, $question->getDefault());
 }
 public function testValidateChoicesWithShortcuts()
 {
     $ir = new InformationRequest('fruit', array('type' => 'choice', 'choices' => array('apple', 'banana', 'cherry'), 'choices_shortcuts' => array('a' => 'apple', 'b' => 'banana', 'c' => 'cherry')));
     $iq = new InteractiveQuestion($ir);
     $this->assertEquals('apple', $iq->validate('a'));
 }