26
26
*/
27
27
class ContainerDataCollector extends DataCollector
28
28
{
29
+ /**
30
+ * @var Kernel
31
+ */
29
32
protected $ kernel ;
30
- protected $ container ;
33
+
34
+ /**
35
+ * @var ContainerBuilder
36
+ */
31
37
protected $ containerBuilder ;
32
38
33
39
/**
@@ -39,8 +45,6 @@ class ContainerDataCollector extends DataCollector
39
45
public function __construct (Kernel $ kernel , $ displayInWdt )
40
46
{
41
47
$ this ->kernel = $ kernel ;
42
- $ this ->container = $ kernel ->getContainer ();
43
- $ this ->containerBuilder = $ this ->getContainerBuilder ();
44
48
$ this ->data ['display_in_wdt ' ] = $ displayInWdt ;
45
49
}
46
50
@@ -66,6 +70,8 @@ public function collect(Request $request, Response $response, \Exception $except
66
70
$ parameters = array ();
67
71
$ services = array ();
68
72
73
+ $ this ->loadContainerBuilder ();
74
+
69
75
if ($ this ->containerBuilder !== false ) {
70
76
foreach ($ this ->containerBuilder ->getParameterBag ()->all () as $ key => $ value ) {
71
77
$ service = substr ($ key , 0 , strpos ($ key , '. ' ));
@@ -143,23 +149,27 @@ public function getName()
143
149
*
144
150
* @author Ryan Weaver <ryan@thatsquality.com>
145
151
*
146
- * @return ContainerBuilder
147
152
*/
148
- private function getContainerBuilder ()
153
+ private function loadContainerBuilder ()
149
154
{
155
+ if ($ this ->containerBuilder !== null ) {
156
+ return ;
157
+ }
158
+ $ container = $ this ->kernel ->getContainer ();
150
159
if (!$ this ->getKernel ()->isDebug ()
151
- || !$ this -> container ->hasParameter ('debug.container.dump ' )
152
- || !file_exists ($ cachedFile = $ this -> container ->getParameter ('debug.container.dump ' ))
160
+ || !$ container ->hasParameter ('debug.container.dump ' )
161
+ || !file_exists ($ cachedFile = $ container ->getParameter ('debug.container.dump ' ))
153
162
) {
154
- return false ;
163
+ $ this ->containerBuilder = false ;
164
+ return ;
155
165
}
156
166
157
- $ container = new ContainerBuilder ();
167
+ $ containerBuilder = new ContainerBuilder ();
158
168
159
- $ loader = new XmlFileLoader ($ container , new FileLocator ());
169
+ $ loader = new XmlFileLoader ($ containerBuilder , new FileLocator ());
160
170
$ loader ->load ($ cachedFile );
161
171
162
- return $ container ;
172
+ $ this -> containerBuilder = $ containerBuilder ;
163
173
}
164
174
165
175
/**
0 commit comments