File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -1534,11 +1534,15 @@ protected function getEnv($name)
1534
1534
return $ value ;
1535
1535
}
1536
1536
1537
- foreach ( $ bag ->getEnvPlaceholders () as $ env => $ placeholders ) {
1538
- if (isset ($ placeholders [$ value ])) {
1539
- $ bag = new ParameterBag ($ bag ->all ());
1537
+ $ envPlaceholders = $ bag ->getEnvPlaceholders ();
1538
+ if (isset ($ envPlaceholders [ $ name ] [$ value ])) {
1539
+ $ bag = new ParameterBag ($ bag ->all ());
1540
1540
1541
- return $ bag ->unescapeValue ($ bag ->get ("env( $ name) " ));
1541
+ return $ bag ->unescapeValue ($ bag ->get ("env( $ name) " ));
1542
+ }
1543
+ foreach ($ envPlaceholders as $ env => $ placeholders ) {
1544
+ if (isset ($ placeholders [$ value ])) {
1545
+ return $ this ->getEnv ($ env );
1542
1546
}
1543
1547
}
1544
1548
Original file line number Diff line number Diff line change @@ -738,6 +738,20 @@ public function testDynamicEnv()
738
738
$ this ->assertSame ('someFooBar ' , $ container ->getParameter ('baz ' ));
739
739
}
740
740
741
+ public function testFallbackEnv ()
742
+ {
743
+ putenv ('DUMMY_FOO=foo ' );
744
+
745
+ $ container = new ContainerBuilder ();
746
+ $ container ->setParameter ('foo ' , '%env(DUMMY_FOO)% ' );
747
+ $ container ->setParameter ('bar ' , 'bar%env(default:foo:DUMMY_BAR)% ' );
748
+
749
+ $ container ->compile (true );
750
+ putenv ('DUMMY_FOO ' );
751
+
752
+ $ this ->assertSame ('barfoo ' , $ container ->getParameter ('bar ' ));
753
+ }
754
+
741
755
public function testCastEnv ()
742
756
{
743
757
$ container = new ContainerBuilder ();
You can’t perform that action at this time.
0 commit comments