10000 [FrameworkBundle] Add `resolve-env` option to debug:config command · symfony/symfony@bdc8e02 · GitHub
[go: up one dir, main page]

Skip to content

Commit bdc8e02

Browse files
[FrameworkBundle] Add resolve-env option to debug:config command
1 parent 8a6fa52 commit bdc8e02

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Exception\LogicException;
2020
use Symfony\Component\Console\Input\InputArgument;
2121
use Symfony\Component\Console\Input\InputInterface;
22+
use Symfony\Component\Console\Input\InputOption;
2223
use Symfony\Component\Console\Output\OutputInterface;
2324
use Symfony\Component\Console\Style\SymfonyStyle;
2425
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
@@ -46,6 +47,7 @@ protected function configure()
4647
->setDefinition([
4748
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
4849
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
50+
new InputOption('resolve-env', null, InputOption::VALUE_NONE, 'Display resolved environment variable values instead of placeholders'),
4951
])
5052
->setHelp(<<<'EOF'
5153
The <info>%command.name%</info> command dumps the current configuration for an
@@ -94,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9496
$extensionAlias = $extension->getAlias();
9597
$container = $this->compileContainer();
9698

97-
$config = $this->getConfig($extension, $container);
99+
$config = $this->getConfig($extension, $container, $input->getOption('resolve-env'));
98100

99101
if (null === $path = $input->getArgument('path')) {
100102
$io->title(
@@ -210,12 +212,12 @@ private function getAvailableBundles(bool $alias): array
210212
return $availableBundles;
211213
}
212214

213-
private function getConfig(ExtensionInterface $extension, ContainerBuilder $container)
215+
private function getConfig(ExtensionInterface $extension, ContainerBuilder $container, bool $resolveEnvs = false)
214216
{
215217
return $container->resolveEnvPlaceholders(
216218
$container->getParameterBag()->resolveValue(
217219
$this->getConfigForExtension($extension, $container)
218-
)
220+
), $resolveEnvs ?: null
219221
);
220222
}
221223

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ public function testParametersValuesAreResolved()
6060
$this->assertStringContainsString('secret: test', $tester->getDisplay());
6161
}
6262

63+
public function testParametersValuesAreFullyResolved()
64+
{
65+
$tester = $this->createCommandTester();
66+
$ret = $tester->execute(['name' => 'framework', '--resolve-env' => true]);
67+
68+
$this->assertSame(0, $ret, 'Returns 0 in case of success');
69+
$this->assertStringContainsString('locale: en', $tester->getDisplay());
70+
$this->assertStringContainsString('secret: test', $tester->getDisplay());
71+
$this->assertStringContainsString('cookie_httponly: true', $tester->getDisplay());
72+
$this->assertStringContainsString('ide: null', $tester->getDisplay());
73+
}
74+
6375
public function testDefaultParameterValueIsResolvedIfConfigIsExisting()
6476
{
6577
$tester = $this->createCommandTester();

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Add argument `&$asGhostObject` to LazyProxy's `DumperInterface` to allow using ghost objects for lazy loading services
99
* Add `enum` env var processor
1010
* Add `shuffle` env var processor
11+
* Add `resolve-env` option to `debug:config` command to display actual values of environment variables in dumped configuration
1112

1213
6.1
1314
---

0 commit comments

Comments
 (0)
0