|
15 | 15 | use Symfony\Component\Console\Input\InputInterface;
|
16 | 16 | use Symfony\Component\Console\Input\InputOption;
|
17 | 17 | use Symfony\Component\Console\Output\OutputInterface;
|
| 18 | +use Symfony\Component\Console\Helper\DialogHelper; |
| 19 | +use Symfony\Component\Console\Helper\QuestionHelper; |
| 20 | +use Symfony\Component\Console\Question\Question; |
18 | 21 |
|
19 | 22 | /**
|
20 | 23 | * A console command for creating and sending simple emails
|
@@ -85,12 +88,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
85 | 88 | */
|
86 | 89 | protected function interact(InputInterface $input, OutputInterface $output)
|
87 | 90 | {
|
88 |
| - $dialog = $this->getHelper('dialog'); |
| 91 | + // Symfony <2.5 BC |
| 92 | + /** @var QuestionHelper|DialogHelper $questionHelper */ |
| 93 | + $questionHelper = $this->getHelperSet()->has('question') ? $this->getHelperSet()->get('question') : $this->getHelperSet()->get('dialog'); |
| 94 | + |
89 | 95 | foreach ($input->getOptions() as $option => $value) {
|
90 | 96 | if ($value === null) {
|
91 |
| - $input->setOption($option, $dialog->ask($output, |
92 |
| - sprintf('<question>%s</question>: ', ucfirst($option)) |
93 |
| - )); |
| 97 | + // Symfony <2.5 BC |
| 98 | + if ($questionHelper instanceof QuestionHelper) { |
| 99 | + $question = new Question(sprintf('<question>%s</question>: ', ucfirst($option))); |
| 100 | + } else { |
| 101 | + $question = sprintf('<question>%s</question>: ', ucfirst($option)); |
| 102 | + } |
| 103 | + $input->setOption($option, $questionHelper->ask($input, $output, $question)); |
94 | 104 | }
|
95 | 105 | }
|
96 | 106 | }
|
|
0 commit comments