diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index 7d3373f3ebbf..4761b66ad901 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -11,12 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Command; -use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Yaml\Yaml; @@ -80,15 +80,19 @@ protected function execute(InputInterface $input, OutputInterface $output) $container = $this->compileContainer(); $extensionAlias = $extension->getAlias(); - $configs = $container->getExtensionConfig($extensionAlias); - $configuration = $extension->getConfiguration($configs, $container); - - $this->validateConfiguration($extension, $configuration); + $extensionConfig = []; + foreach ($container->getCompilerPassConfig()->getPasses() as $pass) { + if ($pass instanceof ValidateEnvPlaceholdersPass) { + $extensionConfig = $pass->getExtensionConfig(); + break; + } + } - $configs = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($configs)); + if (!isset($extensionConfig[$extensionAlias])) { + throw new \LogicException(sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias)); + } - $processor = new Processor(); - $config = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($processor->processConfiguration($configuration, $configs))); + $config = $container->resolveEnvPlaceholders($extensionConfig[$extensionAlias]); if (null === $path = $input->getArgument('path')) { $io->title( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php index 2c0a75481b39..f52d48e89904 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php @@ -66,6 +66,14 @@ public function testDumpUndefinedBundleOption() $this->assertContains('Unable to find configuration for "test.foo"', $tester->getDisplay()); } + public function testDumpWithPrefixedEnv() + { + $tester = $this->createCommandTester(); + $tester->execute(['name' => 'FrameworkBundle']); + + $this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay()); + } + /** * @return CommandTester */ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml index c1d128804605..432e35bd2f24 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml @@ -4,7 +4,10 @@ imports: framework: secret: '%secret%' default_locale: '%env(LOCALE)%' + session: + cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%' parameters: env(LOCALE): en + env(COOKIE_HTTPONLY): '1' secret: test diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php index 1848ec4dbcba..8fd84fac00ee 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php @@ -28,11 +28,15 @@ class ValidateEnvPlaceholdersPass implements CompilerPassInterface { private static $typeFixtures = ['array' => [], 'bool' => false, 'float' => 0.0, 'int' => 0, 'string' => '']; + private $extensionConfig = []; + /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { + $this->extensionConfig = []; + if (!class_exists(BaseNode::class) || !$extensions = $container->getExtensions()) { return; } @@ -77,7 +81,7 @@ public function process(ContainerBuilder $container) } try { - $processor->processConfiguration($configuration, $config); + $this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config); } catch (TreeWithoutRootNodeException $e) { } } @@ -88,6 +92,18 @@ public function process(ContainerBuilder $container) $resolvingBag->clearUnusedEnvPlaceholders(); } + /** + * @internal + */ + public function getExtensionConfig(): array + { + try { + return $this->extensionConfig; + } finally { + $this->extensionConfig = []; + } + } + private static function getType($value): string { switch ($type = \gettype($value)) {