Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
Expand Down Expand Up @@ -46,6 +47,7 @@ protected function configure()
->setDefinition([
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
new InputOption('resolve-env', null, InputOption::VALUE_NONE, 'Display resolved environment variable values instead of placeholders'),
])
->setHelp(<<<'EOF'
The <info>%command.name%</info> command dumps the current configuration for an
Expand Down Expand Up @@ -94,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$extensionAlias = $extension->getAlias();
$container = $this->compileContainer();

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

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

private function getConfig(ExtensionInterface $extension, ContainerBuilder $container)
private function getConfig(ExtensionInterface $extension, ContainerBuilder $container, bool $resolveEnvs = false)
{
return $container->resolveEnvPlaceholders(
$container->getParameterBag()->resolveValue(
$this->getConfigForExtension($extension, $container)
)
), $resolveEnvs ?: null
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ public function testParametersValuesAreResolved()
$this->assertStringContainsString('secret: test', $tester->getDisplay());
}

public function testParametersValuesAreFullyResolved()
{
$tester = $this->createCommandTester();
$ret = $tester->execute(['name' => 'framework', '--resolve-env' => true]);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertStringContainsString('locale: en', $tester->getDisplay());
$this->assertStringContainsString('secret: test', $tester->getDisplay());
$this->assertStringContainsString('cookie_httponly: true', $tester->getDisplay());
$this->assertStringContainsString('ide: null', $tester->getDisplay());
}

public function testDefaultParameterValueIsResolvedIfConfigIsExisting()
{
$tester = $this->createCommandTester();
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Add argument `&$asGhostObject` to LazyProxy's `DumperInterface` to allow using ghost objects for lazy loading services
* Add `enum` env var processor
* Add `shuffle` env var processor
* Add `resolve-env` option to `debug:config` command to display actual values of environment variables in dumped configuration

6.1
---
Expand Down