|
6 | 6 | use PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper;
|
7 | 7 | use PHPCR\Util\Console\Helper\PhpcrHelper;
|
8 | 8 | use Symfony\Component\Console\Command\Command;
|
9 |
| -use Symfony\Component\Console\Helper\DialogHelper; |
10 | 9 | use Symfony\Component\Console\Helper\QuestionHelper;
|
11 |
| -use Symfony\Component\Console\Input\InputInterface; |
12 |
| -use Symfony\Component\Console\Output\OutputInterface; |
13 |
| -use Symfony\Component\Console\Question\ConfirmationQuestion; |
14 |
| -use Symfony\Component\Console\Question\Question; |
15 | 10 |
|
16 | 11 | /**
|
17 | 12 | * Common base class to help with the helpers.
|
|
21 | 16 | */
|
22 | 17 | abstract class BaseCommand extends Command
|
23 | 18 | {
|
24 |
| - protected $phpcrCliHelper; |
25 |
| - protected $phpcrConsoleDumperHelper; |
26 |
| - |
27 |
| - /** |
28 |
| - * @return SessionInterface |
29 |
| - */ |
30 |
| - protected function getPhpcrSession() |
| 19 | + protected function getPhpcrSession(): SessionInterface |
31 | 20 | {
|
32 | 21 | return $this->getPhpcrHelper()->getSession();
|
33 | 22 | }
|
34 | 23 |
|
35 |
| - /** |
36 |
| - * @return PhpcrHelper |
37 |
| - */ |
38 |
| - protected function getPhpcrHelper() |
39 |
| - { |
40 |
| - return $this->getHelperSet()->get('phpcr'); |
41 |
| - } |
42 |
| - |
43 |
| - /** |
44 |
| - * @return PhpcrConsoleDumperHelper |
45 |
| - */ |
46 |
| - protected function getPhpcrConsoleDumperHelper() |
47 |
| - { |
48 |
| - return $this->getHelperSet()->get('phpcr_console_dumper'); |
49 |
| - } |
50 |
| - |
51 |
| - /** |
52 |
| - * Ask a question with the question helper or the dialog helper for symfony < 2.5 compatibility. |
53 |
| - * |
54 |
| - * @param string $questionText |
55 |
| - * @param string $default |
56 |
| - * |
57 |
| - * @return string |
58 |
| - */ |
59 |
| - protected function ask(InputInterface $input, OutputInterface $output, $questionText, $default = null) |
| 24 | + protected function getPhpcrHelper(): PhpcrHelper |
60 | 25 | {
|
61 |
| - if ($this->getHelperSet()->has('question')) { |
62 |
| - $question = new Question($questionText, $default); |
63 |
| - |
64 |
| - return $this->getQuestionHelper()->ask($input, $output, $question); |
65 |
| - } |
66 |
| - |
67 |
| - return $this->getDialogHelper()->ask($output, $questionText, $default); |
| 26 | + return $this->getHelper('phpcr'); |
68 | 27 | }
|
69 | 28 |
|
70 |
| - /** |
71 |
| - * Ask for confirmation with the question helper or the dialog helper for symfony < 2.5 compatibility. |
72 |
| - * |
73 |
| - * @param string $questionText |
74 |
| - * @param bool $default |
75 |
| - * |
76 |
| - * @return string |
77 |
| - */ |
78 |
| - protected function askConfirmation(InputInterface $input, OutputInterface $output, $questionText, $default = true) |
| 29 | + protected function getPhpcrConsoleDumperHelper(): PhpcrConsoleDumperHelper |
79 | 30 | {
|
80 |
| - if ($this->getHelperSet()->has('question')) { |
81 |
| - $question = new ConfirmationQuestion($questionText, $default); |
82 |
| - |
83 |
| - return $this->getQuestionHelper()->ask($input, $output, $question); |
84 |
| - } |
85 |
| - |
86 |
| - return $this->getDialogHelper()->askConfirmation($output, $questionText, $default); |
| 31 | + return $this->getHelper('phpcr_console_dumper'); |
87 | 32 | }
|
88 | 33 |
|
89 |
| - private function getQuestionHelper(): QuestionHelper |
| 34 | + protected function getQuestionHelper(): QuestionHelper |
90 | 35 | {
|
91 | 36 | return $this->getHelper('question');
|
92 | 37 | }
|
93 |
| - |
94 |
| - private function getDialogHelper(): DialogHelper |
95 |
| - { |
96 |
| - return $this->getHelper('dialog'); |
97 |
| - } |
98 | 38 | }
|
0 commit comments