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 function PHPPM \register_file ;
@@ -63,30 +62,8 @@ public function getApplication()
63
62
throw new \Exception ("Symfony Kernel class was not found in the configured locations. Given: ' $ class' " );
64
63
}
65
64
66
- //since we need to change some services, we need to manually change some services
67
65
$ app = new $ class ($ this ->appenv , $ this ->debug );
68
66
69
- // We need to change some services, before the boot, because they would
70
- // otherwise be instantiated and passed to other classes which makes it
71
- // impossible to replace them.
72
-
73
- Utils::bindAndCall (function () use ($ app ) {
74
- // init bundles
75
- $ app ->initializeBundles ();
76
-
77
- // init container
78
- $ app ->initializeContainer ();
79
- }, $ app );
80
-
81
- Utils::bindAndCall (function () use ($ app ) {
82
- foreach ($ app ->getBundles () as $ bundle ) {
83
- $ bundle ->setContainer ($ app ->container );
84
- $ bundle ->boot ();
85
- }
86
-
87
- $ app ->booted = true ;
88
- }, $ app );
89
-
90
67
if ($ trustedProxies = getenv ('TRUSTED_PROXIES ' )) {
91
68
Request::setTrustedProxies (explode (', ' , $ trustedProxies ), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST );
92
69
}
@@ -119,8 +96,6 @@ protected function getVendorDir()
119
96
*/
120
97
public function preHandle ($ app )
121
98
{
122
- //resets Kernels startTime, so Symfony can correctly calculate the execution time
123
- Utils::hijackProperty ($ app , 'startTime ' , microtime (true ));
124
99
}
125
100
126
101
/**
@@ -133,7 +108,7 @@ public function postHandle($app)
133
108
$ container = $ app ->getContainer ();
134
109
135
110
if ($ container ->has ('doctrine ' )) {
136
- $ doctrineRegistry = $ container ->get (" doctrine " );
111
+ $ doctrineRegistry = $ container ->get (' doctrine ' );
137
112
foreach ($ doctrineRegistry ->getManagers () as $ curManagerName => $ curManager ) {
138
113
if (!$ curManager ->isOpen ()) {
139
114
$ doctrineRegistry ->resetManager ($ curManagerName );
@@ -143,11 +118,6 @@ public function postHandle($app)
143
118
}
144
119
}
145
120
146
- //resets stopwatch, so it can correctly calculate the execution time
147
- if ($ container ->has ('debug.stopwatch ' )) {
148
- $ container ->get ('debug.stopwatch ' )->__construct ();
149
- }
150
-
151
121
//Symfony\Bundle\TwigBundle\Loader\FilesystemLoader
152
122
//->Twig_Loader_Filesystem
153
123
if ($ container ->has ('twig.loader ' )) {
@@ -161,44 +131,12 @@ public function postHandle($app)
161
131
162
132
//reset all profiler stuff currently supported
163
133
if ($ container ->has ('profiler ' )) {
164
- $ profiler = $ container ->get ('profiler ' );
165
-
166
- // since Symfony does not reset Profiler::disable() calls after each request, we need to do it,
167
- // so the profiler bar is visible after the second request as well.
168
- $ profiler ->enable ();
169
-
170
134
//PropelLogger
171
135
if ($ container ->has ('propel.logger ' )) {
172
136
$ propelLogger = $ container ->get ('propel.logger ' );
173
137
Utils::hijackProperty ($ propelLogger , 'queries ' , []);
174
138
}
175
139
176
- //Doctrine
177
- //Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector
178
- if ($ profiler ->has ('db ' )) {
179
- Utils::bindAndCall (function () {
180
- //$logger: \Doctrine\DBAL\Logging\DebugStack
181
- foreach ($ this ->loggers as $ logger ) {
182
- Utils::hijackProperty ($ logger , 'queries ' , []);
183
- }
184
- }, $ profiler ->get ('db ' ), null , 'Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector ' );
185
- }
186
-
187
- //EventDataCollector
188
- if ($ profiler ->has ('events ' )) {
189
- Utils::hijackProperty ($ profiler ->get ('events ' ), 'data ' , [
190
- 'called_listeners ' => [],
191
- 'not_called_listeners ' => [],
192
- ]);
193
- }
194
-
195
- //TwigDataCollector
196
- if ($ profiler ->has ('twig ' )) {
197
- Utils::bindAndCall (function () {
198
- Utils::hijackProperty ($ this ->profile , 'profiles ' , []);
199
- }, $ profiler ->get ('twig ' ));
200
- }
201
-
202
140
//Logger
203
141
if ($ container ->has ('logger ' )) {
204
142
$ logger = $ container ->get ('logger ' );
0 commit comments