Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84fc5f6

Browse files
committed
completion
1 parent e5618ad commit 84fc5f6

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Psr\Container\ContainerInterface;
1515
use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
1616
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Completion\CompletionInput;
18+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1719
use Symfony\Component\Console\Input\InputArgument;
1820
use Symfony\Component\Console\Input\InputInterface;
1921
use Symfony\Component\Console\Input\InputOption;
@@ -56,7 +58,8 @@ protected function configure()
5658
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'),
5759
])
5860
->setDescription(self::$defaultDescription)
59-
->setHelp(<<<'EOF'
61+
->setHelp(
62+
<<<'EOF'
6063
The <info>%command.name%</info> command displays all configured listeners:
6164
6265
<info>php %command.full_name%</info>
@@ -120,6 +123,40 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120123
return 0;
121124
}
122125

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+
123160
private function searchForEvent(EventDispatcherInterface $dispatcher, string $needle): array
124161
{
125162
$output = [];

0 commit comments

Comments
 (0)