Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f5e26ba

Browse filesBrowse files
author
Adrien Jourdier
committed
Fix debug:config completion
1 parent a75f1d7 commit f5e26ba
Copy full SHA for f5e26ba

File tree

2 files changed

+29
-46
lines changed
Filter options

2 files changed

+29
-46
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
+20-16Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,36 +190,26 @@ private function getConfigForExtension(ExtensionInterface $extension, ContainerB
190190
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
191191
{
192192
if ($input->mustSuggestArgumentValuesFor('name')) {
193-
$suggestions->suggestValues($this->getAvailableBundles());
193+
$suggestions->suggestValues($this->getAvailableBundles(!preg_match('/^[A-Z]/', $input->getCompletionValue())));
194194

195195
return;
196196
}
197197

198198
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-
204199
try {
205-
$config = $this->getConfigForPath($this->getConfig($extension, $container), $path, $extensionAlias);
200+
$config = $this->getConfig($this->findExtension($name), $this->compileContainer());
201+
$paths = array_keys(self::buildPathsCompletion($config));
202+
$suggestions->suggestValues($paths);
206203
} catch (LogicException $e) {
207-
$config = [];
208204
}
209-
210-
$suggestions->suggestValues(array_keys($config));
211205
}
212206
}
213207

214-
private function getAvailableBundles(): array
208+
private function getAvailableBundles(bool $alias): array
215209
{
216210
$availableBundles = [];
217211
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
218-
$availableBundles[] = $bundle->getName();
219-
220-
if ($extension = $bundle->getContainerExtension()) {
221-
$availableBundles[] = $extension->getAlias();
222-
}
212+
$availableBundles[] = $alias ? $bundle->getContainerExtension()->getAlias() : $bundle->getName();
223213
}
224214

225215
return $availableBundles;
@@ -233,4 +223,18 @@ private function getConfig(ExtensionInterface $extension, ContainerBuilder $cont
233223
)
234224
);
235225
}
226+
227+
private static function buildPathsCompletion(array $paths, string $prefix = ''): array
228+
{
229+
$completionPaths = [];
230+
foreach ($paths as $key => $values) {
231+
if (\is_array($values)) {
232+
$completionPaths = $completionPaths + self::buildPathsCompletion($values, $prefix.$key.'.');
233+
} else {
234+
$completionPaths[$prefix.$key] = null;
235+
}
236+
}
237+
238+
return $completionPaths;
239+
}
236240
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php
+9-30Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -122,41 +122,20 @@ public function testComplete(array $input, array $expectedSuggestions)
122122

123123
$tester = new CommandCompletionTester($this->application->get('debug:config'));
124124

125-
$suggestions = $tester->complete($input, 2);
125+
$suggestions = $tester->complete($input);
126126

127-
$this->assertSame($expectedSuggestions, $suggestions);
127+
foreach ($expectedSuggestions as $expectedSuggestion) {
128+
$this->assertContains($expectedSuggestion, $suggestions);
129+
}
128130
}
129131

130132
public function provideCompletionSuggestions(): \Generator
131133
{
132-
yield 'name' => [
133-
[''],
134-
[
135-
'DefaultConfigTestBundle',
136-
'default_config_test',
137-
'ExtensionWithoutConfigTestBundle',
138-
'extension_without_config_test',
139-
'FrameworkBundle',
140-
'framework',
141-
'TestBundle',
142-
'test',
143-
],
144-
];
145-
146-
yield 'name with existing path' => [
147-
['framework', 'uid'],
148-
[
149-
'enabled',
150-
'default_uuid_version',
151-
'name_based_uuid_version',
152-
'time_based_uuid_version',
153-
],
154-
];
155-
156-
yield 'name with unknown path' => [
157-
['default_config_test', 'uid'],
158-
[],
159-
];
134+
yield 'name' => [[''], ['default_config_test', 'extension_without_config_test', 'framework', 'test']];
135+
136+
yield 'name (started CamelCase)' => [['Fra'], ['DefaultConfigTestBundle', 'ExtensionWithoutConfigTestBundle', 'FrameworkBundle', 'TestBundle']];
137+
138+
yield 'name with existing path' => [['framework', ''], ['secret', 'router.resource', 'router.utf8', 'router.enabled', 'validation.enabled', 'default_locale']];
160139
}
161140

162141
private function createCommandTester(): CommandTester

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.