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 b9ac3a5

Browse filesBrowse files
committed
Debug finalized config in debug:config
1 parent 7e5dfcf commit b9ac3a5
Copy full SHA for b9ac3a5

File tree

4 files changed

+40
-9
lines changed
Filter options

4 files changed

+40
-9
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
+12-8Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14-
use Symfony\Component\Config\Definition\Processor;
1514
use Symfony\Component\Console\Exception\LogicException;
1615
use Symfony\Component\Console\Input\InputArgument;
1716
use Symfony\Component\Console\Input\InputInterface;
1817
use Symfony\Component\Console\Output\OutputInterface;
1918
use Symfony\Component\Console\Style\SymfonyStyle;
19+
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
2020
use Symfony\Component\DependencyInjection\ContainerBuilder;
2121
use Symfony\Component\Yaml\Yaml;
2222

@@ -80,15 +80,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
$container = $this->compileContainer();
8181

8282
$extensionAlias = $extension->getAlias();
83-
$configs = $container->getExtensionConfig($extensionAlias);
84-
$configuration = $extension->getConfiguration($configs, $container);
85-
86-
$this->validateConfiguration($extension, $configuration);
83+
$extensionConfig = [];
84+
foreach ($container->getCompilerPassConfig()->getPasses() as $pass) {
85+
if ($pass instanceof ValidateEnvPlaceholdersPass) {
86+
$extensionConfig = $pass->getExtensionConfig();
87+
break;
88+
}
89+
}
8790

88-
$configs = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($configs));
91+
if (!isset($extensionConfig[$extensionAlias])) {
92+
throw new \LogicException(sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias));
93+
}
8994

90-
$processor = new Processor();
91-
$config = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($processor->processConfiguration($configuration, $configs)));
95+
$config = $container->resolveEnvPlaceholders($extensionConfig[$extensionAlias]);
9296

9397
if (null === $path = $input->getArgument('path')) {
9498
$io->title(

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public function testDumpUndefinedBundleOption()
6666
$this->assertContains('Unable to find configuration for "test.foo"', $tester->getDisplay());
6767
}
6868

69+
public function testDumpWithPrefixedEnv()
70+
{
71+
$tester = $this->createCommandTester();
72+
$tester->execute(['name' => 'FrameworkBundle']);
73+
74+
$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
75+
}
76+
6977
/**
7078
* @return CommandTester
7179
*/

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ imports:
44
framework:
55
secret: '%secret%'
66
default_locale: '%env(LOCALE)%'
7+
session:
8+
cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'
79

810
parameters:
911
env(LOCALE): en
12+
env(COOKIE_HTTPONLY): '1'
1013
secret: test

‎src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ class ValidateEnvPlaceholdersPass implements CompilerPassInterface
2828
{
2929
private static $typeFixtures = ['array' => [], 'bool' => false, 'float' => 0.0, 'int' => 0, 'string' => ''];
3030

31+
private $extensionConfig = [];
32+
3133
/**
3234
* {@inheritdoc}
3335
*/
3436
public function process(ContainerBuilder $container)
3537
{
38+
$this->extensionConfig = [];
39+
3640
if (!class_exists(BaseNode::class) || !$extensions = $container->getExtensions()) {
3741
return;
3842
}
@@ -77,7 +81,7 @@ public function process(ContainerBuilder $container)
7781
}
7882

7983
try {
80-
$processor->processConfiguration($configuration, $config);
84+
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
8185
} catch (TreeWithoutRootNodeException $e) {
8286
}
8387
}
@@ -88,6 +92,18 @@ public function process(ContainerBuilder $container)
8892
$resolvingBag->clearUnusedEnvPlaceholders();
8993
}
9094

95+
/**
96+
* @internal
97+
*/
98+
public function getExtensionConfig(): array
99+
{
100+
try {
101+
return $this->extensionConfig;
102+
} finally {
103+
$this->extensionConfig = [];
104+
}
105+
}
106+
91107
private static function getType($value): string
92108
{
93109
switch ($type = \gettype($value)) {

0 commit comments

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