@@ -52,16 +52,11 @@ protected function configure()
5252 ->setHelp (<<<'EOF'
5353The <info>%command.name%</info> command dumps the current configuration for an
5454extension/bundle.
55-
5655Either the extension alias or bundle name can be used:
57-
5856 <info>php %command.full_name% framework</info>
5957 <info>php %command.full_name% FrameworkBundle</info>
60-
6158For dumping a specific option, add its path as second argument:
62-
6359 <info>php %command.full_name% framework serializer.enabled</info>
64-
6560EOF
6661 )
6762 ;
@@ -190,36 +185,26 @@ private function getConfigForExtension(ExtensionInterface $extension, ContainerB
190185 public function complete (CompletionInput $ input , CompletionSuggestions $ suggestions ): void
191186 {
192187 if ($ input ->mustSuggestArgumentValuesFor ('name ' )) {
193- $ suggestions ->suggestValues ($ this ->getAvailableBundles ());
188+ $ suggestions ->suggestValues ($ this ->getAvailableBundles (! preg_match ( ' /[A-Z]/ ' , $ input -> getCompletionValue ()[ 0 ] ?? '' ) ));
194189
195190 return ;
196191 }
197192
198193 if ($ input ->mustSuggestArgumentValuesFor ('path ' ) && null !== $ name = $ input ->getArgument ('name ' )) {
199- $ path = $ input ->getArgument ('path ' );
200- $ extension = $ this ->findExtension ($ name );
201- $ extensionAlias = $ extension ->getAlias ();
202- $ container = $ this ->compileContainer ();
203-
204194 try {
205- $ config = $ this ->getConfigForPath ($ this ->getConfig ($ extension , $ container ), $ path , $ extensionAlias );
195+ $ config = $ this ->getConfig ($ this ->findExtension ($ name ), $ this ->compileContainer ());
196+ $ paths = array_keys (self ::buildPathsCompletion ($ config ));
197+ $ suggestions ->suggestValues ($ paths );
206198 } catch (LogicException $ e ) {
207- $ config = [];
208199 }
209-
210- $ suggestions ->suggestValues (array_keys ($ config ));
211200 }
212201 }
213202
214- private function getAvailableBundles (): array
203+ private function getAvailableBundles (bool $ alias ): array
215204 {
216205 $ availableBundles = [];
217206 foreach ($ this ->getApplication ()->getKernel ()->getBundles () as $ bundle ) {
218- $ availableBundles [] = $ bundle ->getName ();
219-
220- if ($ extension = $ bundle ->getContainerExtension ()) {
221- $ availableBundles [] = $ extension ->getAlias ();
222- }
207+ $ availableBundles [] = $ alias ? $ bundle ->getContainerExtension ()->getAlias () : $ bundle ->getName ();
223208 }
224209
225210 return $ availableBundles ;
@@ -233,4 +218,18 @@ private function getConfig(ExtensionInterface $extension, ContainerBuilder $cont
233218 )
234219 );
235220 }
221+
222+ private static function buildPathsCompletion (array $ paths , string $ prefix = '' ): array
223+ {
224+ $ completionPaths = [];
225+ foreach ($ paths as $ key => $ values ) {
226+ if (\is_array ($ values )) {
227+ $ completionPaths = $ completionPaths + self ::buildPathsCompletion ($ values , $ prefix . $ key . '. ' );
228+ } else {
229+ $ completionPaths [$ prefix .$ key ] = null ;
230+ }
231+ }
232+
233+ return $ completionPaths ;
234+ }
236235}
0 commit comments