25
25
use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
26
26
use Symfony \Component \DependencyInjection \Extension \ExtensionInterface ;
27
27
use Symfony \Component \DependencyInjection \ParameterBag \EnvPlaceholderParameterBag ;
28
+ use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
28
29
use Symfony \Component \Config \Resource \FileResource ;
29
30
use Symfony \Component \Config \Resource \ResourceInterface ;
30
31
use Symfony \Component \DependencyInjection \LazyProxy \Instantiator \InstantiatorInterface ;
@@ -555,15 +556,29 @@ public function prependExtensionConfig($name, array $config)
555
556
* * The parameter bag is frozen;
556
557
* * Extension loading is disabled.
557
558
*/
558
- public function compile ()
559
+ public function compile (/* $resolveEnvPlaceholders = false */ )
559
560
{
561
+ if (__CLASS__ !== static ::class) {
562
+ $ r = new \ReflectionMethod ($ this , __FUNCTION__ );
563
+ if (__CLASS__ !== $ r ->getDeclaringClass ()->getName () && (1 > $ r ->getNumberOfParameters () || 'resolveEnvPlaceholders ' !== $ r ->getParameters ()[0 ]->name )) {
564
+ @trigger_error (sprintf ('The %s::compile() method expects a first "$resolveEnvPlaceholders" argument since version 3.3. It will be made mandatory in 4.0. ' , static ::class), E_USER_DEPRECATED );
565
+ }
566
+ }
567
+ $ resolveEnvPlaceholders = 0 < func_num_args () ? func_get_arg (0 ) : false ;
560
568
$ compiler = $ this ->getCompiler ();
561
569
562
570
if ($ this ->trackResources ) {
563
571
foreach ($ compiler ->getPassConfig ()->getPasses () as $ pass ) {
564
572
$ this ->addObjectResource ($ pass );
565
573
}
566
574
}
575
+ $ bag = $ this ->getParameterBag ();
576
+
577
+ if ($ resolveEnvPlaceholders && $ bag instanceof EnvPlaceholderParameterBag) {
578
+ $ this ->parameterBag = new ParameterBag ($ this ->resolveEnvPlaceholders ($ bag ->all (), true ));
579
+ $ this ->envPlaceholders = $ bag ->getEnvPlaceholders ();
580
+ $ this ->parameterBag = $ bag = new ParameterBag ($ this ->resolveEnvPlaceholders ($ this ->parameterBag ->all ()));
581
+ }
567
582
568
583
$ compiler ->compile ($ this );
569
584
@@ -577,7 +592,6 @@ public function compile()
577
592
}
578
593
579
594
$ this ->extensionConfigs = array ();
580
- $ bag = $ this ->getParameterBag ();
581
595
582
596
parent ::compile ();
583
597
0 commit comments