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 cc6d0ae

Browse filesBrowse files
committed
* config:dump-reference
1 parent 85bf403 commit cc6d0ae
Copy full SHA for cc6d0ae

File tree

2 files changed

+49
-0
lines changed
Filter options

2 files changed

+49
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Config\Definition\ConfigurationInterface;
1515
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
1616
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
17+
use Symfony\Component\Console\Completion\CompletionInput;
18+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1719
use Symfony\Component\Console\Exception\InvalidArgumentException;
1820
use Symfony\Component\Console\Input\InputArgument;
1921
use Symfony\Component\Console\Input\InputInterface;
@@ -157,4 +159,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int
157159

158160
return 0;
159161
}
162+
163+
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
164+
{
165+
if ($input->mustSuggestArgumentValuesFor('name')) {
166+
$suggestions->suggestValues($this->getAvailableBundles());
167+
}
168+
169+
if ($input->mustSuggestOptionValuesFor('format')) {
170+
$suggestions->suggestValues($this->getAvailableFormatOptions());
171+
}
172+
}
173+
174+
private function getAvailableBundles(): array
175+
{
176+
$bundles = [];
177+
178+
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
179+
$bundles[] = $bundle->getName();
180+
$bundles[] = $bundle->getContainerExtension()->getAlias();
181+
}
182+
183+
return $bundles;
184+
}
185+
186+
private function getAvailableFormatOptions(): array
187+
{
188+
return ['yaml', 'xml'];
189+
}
160190
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14+
use Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand;
1415
use Symfony\Bundle\FrameworkBundle\Console\Application;
1516
use Symfony\Component\Console\Input\ArrayInput;
1617
use Symfony\Component\Console\Output\NullOutput;
18+
use Symfony\Component\Console\Tester\CommandCompletionTester;
1719
use Symfony\Component\Console\Tester\CommandTester;
1820

1921
/**
@@ -81,6 +83,23 @@ public function testDumpAtPathXml()
8183
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
8284
}
8385

86+
/**
87+
* @dataProvider provideCompletionSuggestions
88+
*/
89+
public function testComplete(array $input, array $expectedSuggestions)
90+
{
91+
$this->application->add(new ConfigDumpReferenceCommand());
92+
$tester = new CommandCompletionTester($this->application->get('config:dump-reference'));
93+
$suggestions = $tester->complete($input, 2);
94+
$this->assertSame($expectedSuggestions, $suggestions);
95+
}
96+
97+
public function provideCompletionSuggestions(): iterable
98+
{
99+
yield 'name' => [[''], ['DefaultConfigTestBundle', 'default_config_test', 'ExtensionWithoutConfigTestBundle', 'extension_without_config_test', 'FrameworkBundle', 'framework', 'TestBundle', 'test']];
100+
yield 'option --format' => [['--format', ''], ['yaml', 'xml']];
101+
}
102+
84103
private function createCommandTester(): CommandTester
85104
{
86105
$command = $this->application->find('config:dump-reference');

0 commit comments

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