|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\Command;
|
13 | 13 |
|
14 | 14 | use Symfony\Bundle\FrameworkBundle\Console\Descriptor\Descriptor;
|
| 15 | +use Symfony\Component\Console\Completion\CompletionInput; |
| 16 | +use Symfony\Component\Console\Completion\CompletionSuggestions; |
15 | 17 | use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
16 | 18 | use Symfony\Component\Console\Input\InputArgument;
|
17 | 19 | use Symfony\Component\Console\Input\InputInterface;
|
@@ -81,7 +83,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
|
81 | 83 | $serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']);
|
82 | 84 |
|
83 | 85 | if ($search = $input->getArgument('search')) {
|
84 |
| - $searchNormalized = preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', '', $search); |
| 86 | + $searchNormalized = preg_replace('/[^a-zA-Z0-9\x7f-\xff $]++/', '', $search); |
| 87 | + |
85 | 88 | $serviceIds = array_filter($serviceIds, function ($serviceId) use ($searchNormalized) {
|
86 | 89 | return false !== stripos(str_replace('\\', '', $serviceId), $searchNormalized) && !str_starts_with($serviceId, '.');
|
87 | 90 | });
|
@@ -162,4 +165,13 @@ private function getFileLink(string $class): string
|
162 | 165 |
|
163 | 166 | return (string) $this->fileLinkFormatter->format($r->getFileName(), $r->getStartLine());
|
164 | 167 | }
|
| 168 | + |
| 169 | + public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void |
| 170 | + { |
| 171 | + if ($input->mustSuggestArgumentValuesFor('search')) { |
| 172 | + $builder = $this->getContainerBuilder($this->getApplication()->getKernel()); |
| 173 | + |
| 174 | + $suggestions->suggestValues(array_filter($builder->getServiceIds(), [$this, 'filterToServiceTypes'])); |
| 175 | + } |
| 176 | + } |
165 | 177 | }
|
0 commit comments