Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Commit de5a2dd

Browse files
committed
bug #125 Fix #124: Symfony 3 : The helper "dialog" is not defined (Anthony ARNAUD)
This PR was squashed before being merged into the 2.3-dev branch (closes #125). Discussion ---------- Fix #124: Symfony 3 : The helper "dialog" is not defined Commits ------- 4f6a432 Fix #124: Symfony 3 : The helper "dialog" is not defined
2 parents 6b7316b + 4f6a432 commit de5a2dd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Command/NewEmailCommand.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Input\InputOption;
1717
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;
1821

1922
/**
2023
* A console command for creating and sending simple emails
@@ -85,12 +88,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
8588
*/
8689
protected function interact(InputInterface $input, OutputInterface $output)
8790
{
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+
8995
foreach ($input->getOptions() as $option => $value) {
9096
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));
94104
}
95105
}
96106
}

0 commit comments

Comments
 (0)