24
24
use Symfony \Component \DependencyInjection \Compiler \CheckTypeDeclarationsPass ;
25
25
use Symfony \Component \DependencyInjection \Compiler \PassConfig ;
26
26
use Symfony \Component \DependencyInjection \Compiler \ResolveFactoryClassPass ;
27
+ use Symfony \Component \DependencyInjection \Compiler \ResolveParameterPlaceHoldersPass ;
27
28
use Symfony \Component \DependencyInjection \Container ;
28
29
use Symfony \Component \DependencyInjection \ContainerBuilder ;
29
30
use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
@@ -49,8 +50,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
49
50
$ io = new SymfonyStyle ($ input , $ output );
50
51
$ errorIo = $ io ->getErrorStyle ();
51
52
53
+ $ resolveEnvVars = $ input ->getOption ('resolve-env-vars ' );
54
+
52
55
try {
53
- $ container = $ this ->getContainerBuilder ();
56
+ $ container = $ this ->getContainerBuilder ($ resolveEnvVars );
54
57
} catch (RuntimeException $ e ) {
55
58
$ errorIo ->error ($ e ->getMessage ());
56
59
@@ -60,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
60
63
$ container ->setParameter ('container.build_time ' , time ());
61
64
62
65
try {
63
- $ container ->compile (( bool ) $ input -> getOption ( ' resolve-env-vars ' ) );
66
+ $ container ->compile ($ resolveEnvVars );
64
67
} catch (InvalidArgumentException $ e ) {
65
68
$ errorIo ->error ($ e ->getMessage ());
66
69
@@ -72,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
72
75
return 0 ;
73
76
}
74
77
75
- private function getContainerBuilder (): ContainerBuilder
78
+ private function getContainerBuilder (bool $ resolveEnvVars ): ContainerBuilder
76
79
{
77
80
if (isset ($ this ->container )) {
78
81
return $ this ->container ;
@@ -99,16 +102,22 @@ private function getContainerBuilder(): ContainerBuilder
99
102
100
103
(new XmlFileLoader ($ container = new ContainerBuilder ($ parameterBag = new EnvPlaceholderParameterBag ()), new FileLocator ()))->load ($ kernelContainer ->getParameter ('debug.container.dump ' ));
101
104
102
- $ refl = new \ReflectionProperty ($ parameterBag , 'resolved ' );
103
- $ refl ->setValue ($ parameterBag , true );
105
+ if ($ resolveEnvVars ) {
106
+ $ container ->getCompilerPassConfig ()->setOptimizationPasses ([new ResolveParameterPlaceHoldersPass (), new ResolveFactoryClassPass ()]);
107
+ } else {
108
+ $ refl = new \ReflectionProperty ($ parameterBag , 'resolved ' );
109
+ $ refl ->setValue ($ parameterBag , true );
110
+
111
+ $ container ->getCompilerPassConfig ()->setOptimizationPasses ([new ResolveFactoryClassPass ()]);
112
+ }
104
113
105
114
$ container ->getCompilerPassConfig ()->setBeforeOptimizationPasses ([]);
106
- $ container ->getCompilerPassConfig ()->setOptimizationPasses ([new ResolveFactoryClassPass ()]);
107
115
$ container ->getCompilerPassConfig ()->setBeforeRemovingPasses ([]);
108
116
}
109
117
110
118
$ container ->setParameter ('container.build_hash ' , 'lint_container ' );
111
119
$ container ->setParameter ('container.build_id ' , 'lint_container ' );
120
+ $ container ->setParameter ('container.runtime_mode ' , 'web=0 ' );
112
121
113
122
$ container ->addCompilerPass (new CheckAliasValidityPass (), PassConfig::TYPE_BEFORE_REMOVING , -100 );
114
123
$ container ->addCompilerPass (new CheckTypeDeclarationsPass (true ), PassConfig::TYPE_AFTER_REMOVING , -100 );
0 commit comments