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 = [])
127127 protected static function ensureKernelShutdown ()
128128 {
129129 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+ }
135139 }
136140 }
137141 static ::$ container = null ;
Original file line number Diff line number Diff line change 1414use Psr \Log \NullLogger ;
1515use Symfony \Component \Config \Loader \LoaderInterface ;
1616use Symfony \Component \DependencyInjection \ContainerBuilder ;
17+ use Symfony \Component \DependencyInjection \ContainerInterface ;
1718use Symfony \Component \Filesystem \Filesystem ;
1819use Symfony \Component \HttpKernel \Kernel ;
1920
@@ -96,4 +97,13 @@ protected function getKernelParameters(): array
9697
9798 return $ parameters ;
9899 }
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+ }
99109}
You can’t perform that action at this time.
0 commit comments