|
14 | 14 | use Psr\Container\ContainerInterface;
|
15 | 15 | use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
|
16 | 16 | use Symfony\Component\Console\Command\Command;
|
| 17 | +use Symfony\Component\Console\Completion\CompletionInput; |
| 18 | +use Symfony\Component\Console\Completion\CompletionSuggestions; |
17 | 19 | use Symfony\Component\Console\Input\InputArgument;
|
18 | 20 | use Symfony\Component\Console\Input\InputInterface;
|
19 | 21 | use Symfony\Component\Console\Input\InputOption;
|
@@ -56,7 +58,8 @@ protected function configure()
|
56 | 58 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'),
|
57 | 59 | ])
|
58 | 60 | ->setDescription(self::$defaultDescription)
|
59 |
| - ->setHelp(<<<'EOF' |
| 61 | + ->setHelp( |
| 62 | + <<<'EOF' |
60 | 63 | The <info>%command.name%</info> command displays all configured listeners:
|
61 | 64 |
|
62 | 65 | <info>php %command.full_name%</info>
|
@@ -120,6 +123,40 @@ protected function execute(InputInterface $input, OutputInterface $output): int
|
120 | 123 | return 0;
|
121 | 124 | }
|
122 | 125 |
|
| 126 | + public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void |
| 127 | + { |
| 128 | + if ($input->mustSuggestArgumentValuesFor('event')) { |
| 129 | + $dispatcherServiceName = $input->getOption('dispatcher'); |
| 130 | + if (!$this->dispatchers->has($dispatcherServiceName)) { |
| 131 | + return; |
| 132 | + } |
| 133 | + |
| 134 | + $dispatcher = $this->dispatchers->get($dispatcherServiceName); |
| 135 | + $suggestions->suggestValues(array_merge( |
| 136 | + $dispatcher->getListeners() |
| 137 | + )); |
| 138 | + |
| 139 | + return; |
| 140 | + } |
| 141 | + |
| 142 | + if ($input->mustSuggestOptionValuesFor('dispatcher')) { |
| 143 | + $suggestions->suggestValues(array_merge( |
| 144 | + $this->dispatchers->getServiceIds(), |
| 145 | + $this->dispatchers->getAliases() |
| 146 | + )); |
| 147 | + |
| 148 | + return; |
| 149 | + } |
| 150 | + |
| 151 | + if ($input->mustSuggestOptionValuesFor('format')) { |
| 152 | + $suggestions->suggestValues( |
| 153 | + (new DescriptorHelper())->getFormats() |
| 154 | + ); |
| 155 | + |
| 156 | + return; |
| 157 | + } |
| 158 | + } |
| 159 | + |
123 | 160 | private function searchForEvent(EventDispatcherInterface $dispatcher, string $needle): array
|
124 | 161 | {
|
125 | 162 | $output = [];
|
|
0 commit comments