File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -127,11 +127,15 @@ protected static function createKernel(array $options = [])
127
127
protected static function ensureKernelShutdown ()
128
128
{
129
129
if (null !== static ::$ kernel ) {
130
- $ container = static ::$ kernel ->getContainer ();
131
- static ::$ kernel ->shutdown ();
132
- static ::$ booted = false ;
133
- if ($ container instanceof ResetInterface) {
134
- $ container ->reset ();
130
+ $ isBooted = (new \ReflectionClass (static ::$ kernel ))->getProperty ('booted ' );
131
+ $ isBooted ->setAccessible (true );
132
+ if ($ isBooted ->getValue (static ::$ kernel )) {
133
+ $ container = static ::$ kernel ->getContainer ();
134
+ static ::$ kernel ->shutdown ();
135
+ static ::$ booted = false ;
136
+ if ($ container instanceof ResetInterface) {
137
+ $ container ->reset ();
138
+ }
135
139
}
136
140
}
137
141
static ::$ container = null ;
Original file line number Diff line number Diff line change 14
14
use Psr \Log \NullLogger ;
15
15
use Symfony \Component \Config \Loader \LoaderInterface ;
16
16
use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
+ use Symfony \Component \DependencyInjection \ContainerInterface ;
17
18
use Symfony \Component \Filesystem \Filesystem ;
18
19
use Symfony \Component \HttpKernel \Kernel ;
19
20
@@ -96,4 +97,13 @@ protected function getKernelParameters(): array
96
97
97
98
return $ parameters ;
98
99
}
100
+
101
+ public function getContainer (): ContainerInterface
102
+ {
103
+ if (!$ this ->booted ) {
104
+ throw new \LogicException ('Cannot access the container on a non-booted kernel. Did you forget to boot it? ' );
105
+ }
106
+
107
+ return parent ::getContainer ();
108
+ }
99
109
}
You can’t perform that action at this time.
0 commit comments