2
2
3
3
namespace PHPPM \Bootstraps ;
4
4
5
- use PHPPM \Symfony \StrongerNativeSessionStorage ;
6
5
use PHPPM \Utils ;
7
6
use Symfony \Component \HttpFoundation \Request ;
8
7
use Symfony \Component \Config \Resource \FileResource ;
9
8
use Symfony \Contracts \Service \ResetInterface ;
10
9
use function PHPPM \register_file ;
10
+ use Symfony \Component \HttpKernel \KernelInterface ;
11
11
12
12
/**
13
13
* A default bootstrap for the Symfony framework
@@ -39,7 +39,7 @@ public function initialize($appenv, $debug)
39
39
/**
40
40
* Create a Symfony application
41
41
*
42
- * @return \AppKernel
42
+ * @return KernelInterface
43
43
* @throws \Exception
44
44
*/
45
45
public function getApplication ()
@@ -68,27 +68,6 @@ public function getApplication()
68
68
//since we need to change some services, we need to manually change some services
69
69
$ app = new $ class ($ this ->appenv , $ this ->debug );
70
70
71
- // We need to change some services, before the boot, because they would
72
- // otherwise be instantiated and passed to other classes which makes it
73
- // impossible to replace them.
74
-
75
- Utils::bindAndCall (function () use ($ app ) {
76
- // init bundles
77
- $ app ->initializeBundles ();
78
-
79
- // init container
80
- $ app ->initializeContainer ();
81
- }, $ app );
82
-
83
- Utils::bindAndCall (function () use ($ app ) {
84
- foreach ($ app ->getBundles () as $ bundle ) {
85
- $ bundle ->setContainer ($ app ->container );
86
- $ bundle ->boot ();
87
- }
88
-
89
- $ app ->booted = true ;
90
- }, $ app );
91
-
92
71
if ($ this ->debug ) {
93
72
Utils::bindAndCall (function () use ($ app ) {
94
73
$ container = $ app ->container ;
@@ -149,25 +128,23 @@ protected function getVendorDir()
149
128
/**
150
129
* Does some necessary preparation before each request.
151
130
*
152
- * @param \AppKernel $app
131
+ * @param KernelInterface $app
153
132
*/
154
133
public function preHandle ($ app )
155
134
{
156
- //resets Kernels startTime, so Symfony can correctly calculate the execution time
157
- Utils::hijackProperty ($ app , 'startTime ' , microtime (true ));
158
135
}
159
136
160
137
/**
161
138
* Does some necessary clean up after each request.
162
139
*
163
- * @param \AppKernel $app
140
+ * @param KernelInterface $app
164
141
*/
165
142
public function postHandle ($ app )
166
143
{
167
144
$ container = $ app ->getContainer ();
168
145
169
146
if ($ container ->has ('doctrine ' )) {
170
- $ doctrineRegistry = $ container ->get (" doctrine " );
147
+ $ doctrineRegistry = $ container ->get (' doctrine ' );
171
148
if (!$ doctrineRegistry instanceof ResetInterface) {
172
149
foreach ($ doctrineRegistry ->getManagers () as $ curManagerName => $ curManager ) {
173
150
if (!$ curManager ->isOpen ()) {
@@ -179,11 +156,6 @@ public function postHandle($app)
179
156
}
180
157
}
181
158
182
- //resets stopwatch, so it can correctly calculate the execution time
183
- if ($ container ->has ('debug.stopwatch ' )) {
184
- $ container ->get ('debug.stopwatch ' )->__construct ();
185
- }
186
-
187
159
//Symfony\Bundle\TwigBundle\Loader\FilesystemLoader
188
160
//->Twig_Loader_Filesystem
189
161
if ($ this ->debug && $ container ->has ('twig.loader ' )) {
@@ -195,83 +167,10 @@ public function postHandle($app)
195
167
}, $ twigLoader );
196
168
}
197
169
198
- //reset Webpack Encore file list
199
- Utils::bindAndCall (function () use ($ container ) {
200
- if (isset ($ container ->privates ['webpack_encore.entrypoint_lookup ' ])) {
201
- $ container ->privates ['webpack_encore.entrypoint_lookup ' ]->reset ();
202
- }
203
- }, $ container );
204
-
205
170
//reset all profiler stuff currently supported
206
- if ($ container ->has ('profiler ' )) {
207
- $ profiler = $ container ->get ('profiler ' );
208
-
209
- // since Symfony does not reset Profiler::disable() calls after each request, we need to do it,
210
- // so the profiler bar is visible after the second request as well.
211
- $ profiler ->enable ();
212
-
213
- //PropelLogger
214
- if ($ container ->has ('propel.logger ' )) {
215
- $ propelLogger = $ container ->get ('propel.logger ' );
216
- Utils::hijackProperty ($ propelLogger , 'queries ' , []);
217
- }
218
-
219
- //Doctrine
220
- //Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector
221
- if ($ profiler ->has ('db ' )) {
222
- Utils::bindAndCall (function () {
223
- //$logger: \Doctrine\DBAL\Logging\DebugStack
224
- foreach ($ this ->loggers as $ logger ) {
225
- Utils::hijackProperty ($ logger , 'queries ' , []);
226
- }
227
- }, $ profiler ->get ('db ' ), null , 'Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector ' );
228
- }
229
-
230
- //EventDataCollector
231
- if ($ profiler ->has ('events ' )) {
232
- Utils::hijackProperty ($ profiler ->get ('events ' ), 'data ' , [
233
- 'called_listeners ' => [],
234
- 'not_called_listeners ' => [],
235
- ]);
236
- }
237
-
238
- //TwigDataCollector
239
- if ($ profiler ->has ('twig ' )) {
240
- Utils::bindAndCall (function () {
241
- Utils::hijackProperty ($ this ->profile , 'profiles ' , []);
242
- }, $ profiler ->get ('twig ' ));
243
- }
244
-
245
- //Logger
246
- if ($ container ->has ('logger ' )) {
247
- $ logger = $ container ->get ('logger ' );
248
- Utils::bindAndCall (function () {
249
- if (\method_exists ($ this , 'getDebugLogger ' ) && $ debugLogger = $ this ->getDebugLogger ()) {
250
- //DebugLogger
251
- Utils::hijackProperty ($ debugLogger , 'records ' , []);
252
- }
253
- }, $ logger );
254
- }
255
-
256
- //SwiftMailer logger
257
- //Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector
258
- if ($ container ->hasParameter ('swiftmailer.mailers ' )) {
259
- $ mailers = $ container ->getParameter ('swiftmailer.mailers ' );
260
- foreach ($ mailers as $ name => $ mailer ) {
261
- $ loggerName = sprintf ('swiftmailer.mailer.%s.plugin.messagelogger ' , $ name );
262
- if ($ container ->has ($ loggerName )) {
263
- /** @var \Swift_Plugins_MessageLogger $logger */
264
- $ logger = $ container ->get ($ loggerName );
265
- $ logger ->clear ();
266
- }
267
- }
268
- }
269
-
270
- //Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector
271
- if ($ container ->has ('swiftmailer.plugin.messagelogger ' )) {
272
- $ logger = $ container ->get ('swiftmailer.plugin.messagelogger ' );
273
- $ logger ->clear ();
274
- }
171
+ if ($ container ->has ('propel.logger ' )) {
172
+ $ propelLogger = $ container ->get ('propel.logger ' );
173
+ Utils::hijackProperty ($ propelLogger , 'queries ' , []);
275
174
}
276
175
}
277
176
}
0 commit comments