4
4
5
5
namespace Tests \Setono \SyliusFacebookTrackingPlugin \Application ;
6
6
7
- use ProxyManager \Proxy \VirtualProxyInterface ;
8
7
use PSS \SymfonyMockerContainer \DependencyInjection \MockerContainer ;
9
8
use Symfony \Bundle \FrameworkBundle \Kernel \MicroKernelTrait ;
10
9
use Symfony \Component \Config \Loader \DelegatingLoader ;
@@ -31,13 +30,6 @@ final class Kernel extends BaseKernel
31
30
32
31
private const CONFIG_EXTS = '.{php,xml,yaml,yml} ' ;
33
32
34
- private const IGNORED_SERVICES_DURING_CLEANUP = [
35
- 'kernel ' ,
36
- 'http_kernel ' ,
37
- 'liip_imagine.mime_type_guesser ' ,
38
- 'liip_imagine.extension_guesser ' ,
39
- ];
40
-
41
33
public function getCacheDir (): string
42
34
{
43
35
return $ this ->getProjectDir () . '/var/cache/ ' . $ this ->environment ;
@@ -58,25 +50,6 @@ public function registerBundles(): iterable
58
50
}
59
51
}
60
52
61
- public function shutdown (): void
62
- {
63
- if (!$ this ->isTestEnvironment ()) {
64
- parent ::shutdown ();
65
-
66
- return ;
67
- }
68
-
69
- if (false === $ this ->booted ) {
70
- return ;
71
- }
72
-
73
- $ container = $ this ->getContainer ();
74
-
75
- parent ::shutdown ();
76
-
77
- $ this ->cleanupContainer ($ container );
78
- }
79
-
80
53
protected function configureContainer (ContainerBuilder $ container , LoaderInterface $ loader ): void
81
54
{
82
55
$ container ->addResource (new FileResource ($ this ->getProjectDir () . '/config/bundles.php ' ));
@@ -130,45 +103,4 @@ private function isTestEnvironment(): bool
130
103
{
131
104
return 0 === strpos ($ this ->getEnvironment (), 'test ' );
132
105
}
133
-
134
- /**
135
- * Remove all container references from all loaded services
136
- */
137
- private function cleanupContainer (ContainerInterface $ container ): void
138
- {
139
- $ containerReflection = new \ReflectionObject ($ container );
140
- $ containerServicesPropertyReflection = $ containerReflection ->getProperty ('services ' );
141
- $ containerServicesPropertyReflection ->setAccessible (true );
142
-
143
- $ services = $ containerServicesPropertyReflection ->getValue ($ container ) ?: [];
144
- foreach ($ services as $ serviceId => $ service ) {
145
- if (null === $ service ) {
146
- continue ;
147
- }
148
-
149
- if (in_array ($ serviceId , self ::IGNORED_SERVICES_DURING_CLEANUP , true )) {
150
- continue ;
151
- }
152
-
153
- $ serviceReflection = new \ReflectionObject ($ service );
154
-
155
- if ($ serviceReflection ->implementsInterface (VirtualProxyInterface::class)) {
156
- continue ;
157
- }
158
-
159
- $ servicePropertiesReflections = $ serviceReflection ->getProperties ();
160
- $ servicePropertiesDefaultValues = $ serviceReflection ->getDefaultProperties ();
161
- foreach ($ servicePropertiesReflections as $ servicePropertyReflection ) {
162
- $ defaultPropertyValue = null ;
163
- if (isset ($ servicePropertiesDefaultValues [$ servicePropertyReflection ->getName ()])) {
164
- $ defaultPropertyValue = $ servicePropertiesDefaultValues [$ servicePropertyReflection ->getName ()];
165
- }
166
-
167
- $ servicePropertyReflection ->setAccessible (true );
168
- $ servicePropertyReflection ->setValue ($ service , $ defaultPropertyValue );
169
- }
170
- }
171
-
172
- $ containerServicesPropertyReflection ->setValue ($ container , null );
173
- }
174
106
}
0 commit comments