Skip to content

Commit 68ff160

Browse files
committed
symfony/dependency-injection ^4.0 compatibility
1 parent a92ca8a commit 68ff160

File tree

7 files changed

+311
-196
lines changed

7 files changed

+311
-196
lines changed

Bridge/ContainerIntrospectionBundle/DataCollector/ContainerIntrospectionCollector.php

+26-18
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,25 @@ public function getName(): string
2828

2929
public function collect(Request $request, Response $response, \Exception $exception = null): void
3030
{
31+
$this->introspection->introspect();
32+
3133
$this->data = [
3234
'containerCachePath' => $this->introspection->getContainerCachePath(),
3335
'containerCacheDir' => $this->introspection->getContainerCacheDir(),
3436
'countContainerCacheFiles' => $this->introspection->countContainerCacheFiles(),
3537
'countContainerCacheLines' => $this->introspection->countContainerCacheLines(),
3638
'containerCacheSize' => $this->introspection->getContainerCacheSize(),
3739

38-
'registeredServices' => $this->introspection->getRegisteredServices(),
39-
'countRegisteredServices' => $this->introspection->countRegisteredServices(),
40+
'countServices' => $this->introspection->countServices(),
4041

4142
'instantiatedServices' => $this->introspection->getInstantiatedServices(),
4243
'countInstanciatedServices' => $this->introspection->countInstantiatedServices(),
4344

4445
'publicServices' => $this->introspection->getPublicServices(),
4546
'countPublicServices' => $this->introspection->countPublicServices(),
4647

47-
'privateServices' => $this->introspection->getPrivateServices(),
48-
'countPrivateServices' => $this->introspection->countPrivateServices(),
48+
'removedServices' => $this->introspection->getRemovedServices(),
49+
'countRemovedServices' => $this->introspection->countRemovedServices(),
4950

5051
'parameters' => $this->introspection->getParameters(),
5152
'countParameters' => $this->introspection->countParameters()
@@ -82,16 +83,6 @@ public function getContainerCacheSize(): int
8283
return $this->data['containerCacheSize'];
8384
}
8485

85-
public function getRegisteredServices(): array
86-
{
87-
return $this->data['registeredServices'];
88-
}
89-
90-
public function countRegisteredServices(): int
91-
{
92-
return $this->data['countRegisteredServices'];
93-
}
94-
9586
public function getInstantiatedServices(): array
9687
{
9788
return $this->data['instantiatedServices'];
@@ -112,14 +103,14 @@ public function countPublicServices(): int
112103
return $this->data['countPublicServices'];
113104
}
114105

115-
public function getPrivateServices(): array
106+
public function getRemovedServices(): array
116107
{
117-
return $this->data['privateServices'];
108+
return $this->data['removedServices'];
118109
}
119110

120-
public function countPrivateServices(): int
111+
public function countRemovedServices(): int
121112
{
122-
return $this->data['countPrivateServices'];
113+
return $this->data['countRemovedServices'];
123114
}
124115

125116
public function getParameters(): array
@@ -131,4 +122,21 @@ public function countParameters(): int
131122
{
132123
return $this->data['countParameters'];
133124
}
125+
126+
public function countServices(): int
127+
{
128+
return $this->data['countServices'];
129+
}
130+
131+
public function getInstantiatedInfos(string $id): ?array
132+
{
133+
$services = $this->getInstantiatedServices();
134+
135+
return array_key_exists($id, $services) ? $services[$id] : null;
136+
}
137+
138+
public function dumpParameterValue($data): void
139+
{
140+
echo var_export($data, true);
141+
}
134142
}

Bridge/ContainerIntrospectionBundle/Resources/views/DataCollector/container.html.twig

+76-68
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

3+
{% macro serviceInstantiation(infos) %}
4+
{% if infos is null %}
5+
Not instantiated
6+
{% elseif infos.ocramiusLazy %}
7+
<span class="label status-warning">Ocramius Lazy</span>
8+
{% else %}
9+
<span class="label status-success">Normal</span>
10+
{% endif %}
11+
{% endmacro %}
12+
313
{% block toolbar %}
414
{% set icon %}
515
{{ include('@ContainerIntrospection/DataCollector/container.svg') }}
6-
<span class="sf-toolbar-value">{{ collector.countInstantiatedServices()|localizednumber }} / {{ collector.countRegisteredServices()|localizednumber }}</span>
16+
<span class="sf-toolbar-value">
17+
{{ collector.countInstantiatedServices()|number_format(0, '.', ',') }}
18+
/ {{ collector.countServices()|number_format(0, '.', ',') }}
19+
</span>
720
{% endset %}
821

922
{% set text %}
1023
<div class="sf-toolbar-info-piece">
11-
<b>Instantiated services</b>
12-
<span>{{ collector.countInstantiatedServices()|localizednumber }}</span>
24+
<b>Instantiated</b>
25+
<span>{{ collector.countInstantiatedServices()|number_format(0, '.', ',') }}</span>
1326
</div>
1427

1528
<div class="sf-toolbar-info-piece">
16-
<b>Registered services</b>
17-
<span>{{ collector.countRegisteredServices()|localizednumber }}</span>
29+
<b>Removed</b>
30+
<span>{{ collector.countRemovedServices()|number_format(0, '.', ',') }}</span>
1831
</div>
1932

2033
<div class="sf-toolbar-info-piece">
21-
<b>Public services</b>
22-
<span>{{ collector.countPublicServices()|localizednumber }}</span>
34+
<b>Public</b>
35+
<span>{{ collector.countPublicServices()|number_format(0, '.', ',') }}</span>
2336
</div>
2437

2538
<div class="sf-toolbar-info-piece">
26-
<b>Private services</b>
27-
<span>{{ collector.countPrivateServices()|localizednumber }}</span>
39+
<b>Total</b>
40+
<span>{{ collector.countServices()|number_format(0, '.', ',') }}</span>
2841
</div>
2942

3043
<div class="sf-toolbar-info-piece">
3144
<b>Parameters</b>
32-
<span>{{ collector.countParameters()|localizednumber }}</span>
45+
<span>{{ collector.countParameters()|number_format(0, '.', ',') }}</span>
3346
</div>
3447
{% endset %}
3548

@@ -59,20 +72,39 @@
5972
color: #8959A8;
6073
font-weight: bold;
6174
}
75+
76+
.label.visibility-public {
77+
background: #269cce;
78+
color: #FFF;
79+
}
80+
81+
.label.visibility-private {
82+
background: #666666;
83+
color: #FFF;
84+
}
6285
</style>
6386
{% endblock %}
6487

6588
{% block panel %}
89+
{% import _self as self %}
90+
6691
<h2>Statistics</h2>
6792

6893
<div class="metrics">
6994
<div class="metric">
7095
<span class="value" title="{{ collector.getContainerCachePath() }}">{{ collector.getContainerCacheDir() }}</span>
71-
<span class="label">Cache dir</span>
96+
<span class="label">Container</span>
7297
</div>
7398

7499
<div class="metric">
75-
<span class="value">{{ collector.countContainerCacheFiles() }}</span>
100+
<span class="value" title="{{ collector.countServices()|number_format(0, '.', ',') }}">
101+
{{ collector.countServices()|number_format(0, '.', ',') }}
102+
</span>
103+
<span class="label">Services</span>
104+
</div>
105+
106+
<div class="metric">
107+
<span class="value">{{ collector.countContainerCacheFiles()|number_format(0, '.', ',') }}</span>
76108
<span class="label">Cache files</span>
77109
</div>
78110

@@ -92,29 +124,35 @@
92124
<div class="sf-tabs">
93125
<div class="tab">
94126
<h3 class="tab-title">
95-
Instantiated services
96-
<span class="badge">{{ collector.countInstantiatedServices()|localizednumber }}</span>
127+
Instantiated
128+
<span class="badge">{{ collector.countInstantiatedServices()|number_format(0, '.', ',') }}</span>
97129
</h3>
98130

99131
<p class="text-muted">
100-
Note that only shared services are shown here,
132+
Note that only shared (singleton) services are shown here,
101133
we can't handle <a href="https://symfony.com/doc/current/service_container/shared.html" target="_blank">non shared service</a> creation.
102134
</p>
103135

104136
<div class="tab-content">
105137
<table class="table-striped">
106138
<thead>
107139
<tr>
108-
<th>#</th>
109-
<th>Service Id</th>
140+
<th>Visibility</th>
141+
<th>Service id</th>
110142
<th>FQCN</th>
111143
<th>Instantiation</th>
112144
</tr>
113145
</thead>
114146
<tbody>
115147
{% for serviceId, serviceInfos in collector.getInstantiatedServices() %}
116148
<tr>
117-
<td>{{ loop.index }}</td>
149+
<td>
150+
{% if serviceInfos.public %}
151+
<span class="label visibility-public">Public</span>
152+
{% else %}
153+
<span class="label visibility-private">Private</span>
154+
{% endif %}
155+
</td>
118156
<td>
119157
{{ serviceId }}
120158

@@ -166,13 +204,7 @@
166204
<i>Unknown value</i>
167205
{% endif %}
168206
</td>
169-
<td>
170-
{% if serviceInfos.ocramiusLazy %}
171-
<span class="label status-warning">Ocramius Lazy</span>
172-
{% else %}
173-
<span class="label status-success">Normal</span>
174-
{% endif %}
175-
</td>
207+
<td>{{ self.serviceInstantiation(serviceInfos) }}</td>
176208
</tr>
177209
{% endfor %}
178210
</tbody>
@@ -182,48 +214,24 @@
182214

183215
<div class="tab">
184216
<h3 class="tab-title">
185-
Registered services
186-
<span class="badge">{{ collector.countRegisteredServices()|localizednumber }}</span>
217+
Removed
218+
<span class="badge">{{ collector.countRemovedServices()|number_format(0, '.', ',') }}</span>
187219
</h3>
188220

189-
<div class="tab-content">
190-
<table>
191-
<thead>
192-
<tr>
193-
<th>#</th>
194-
<th>Service ID</th>
195-
</tr>
196-
</thead>
197-
<tbody>
198-
{% for service in collector.getRegisteredServices() %}
199-
<tr>
200-
<td>{{ loop.index }}</td>
201-
<td>{{ service }}</td>
202-
</tr>
203-
{% endfor %}
204-
</tbody>
205-
</table>
206-
</div>
207-
</div>
208-
209-
<div class="tab">
210-
<h3 class="tab-title">
211-
Public services
212-
<span class="badge">{{ collector.countPublicServices()|localizednumber }}</span>
213-
</h3>
221+
<p class="text-muted">
222+
Some privates, all inlined and all tagged services are removed from Container.
223+
</p>
214224

215225
<div class="tab-content">
216226
<table>
217227
<thead>
218228
<tr>
219-
<th>#</th>
220-
<th>Service ID</th>
229+
<th>Service id</th>
221230
</tr>
222231
</thead>
223-
<tbody>
224-
{% for service in collector.getPublicServices() %}
232+
<tbody>
233+
{% for service in collector.getRemovedServices() %}
225234
<tr>
226-
<td>{{ loop.index }}</td>
227235
<td>{{ service }}</td>
228236
</tr>
229237
{% endfor %}
@@ -234,23 +242,23 @@
234242

235243
<div class="tab">
236244
<h3 class="tab-title">
237-
Private services
238-
<span class="badge">{{ collector.countPrivateServices()|localizednumber }}</span>
245+
Public
246+
<span class="badge">{{ collector.countPublicServices()|number_format(0, '.', ',') }}</span>
239247
</h3>
240248

241249
<div class="tab-content">
242250
<table>
243251
<thead>
244252
<tr>
245-
<th>#</th>
246-
<th>Service ID</th>
253+
<th>Service id</th>
254+
<th>Instantiated</th>
247255
</tr>
248256
</thead>
249257
<tbody>
250-
{% for service in collector.getPrivateServices() %}
258+
{% for service in collector.getPublicServices() %}
251259
<tr>
252-
<td>{{ loop.index }}</td>
253260
<td>{{ service }}</td>
261+
<td>{{ self.serviceInstantiation(collector.getInstantiatedInfos(service)) }}</td>
254262
</tr>
255263
{% endfor %}
256264
</tbody>
@@ -261,22 +269,22 @@
261269
<div class="tab">
262270
<h3 class="tab-title">
263271
Parameters
264-
<span class="badge">{{ collector.countParameters()|localizednumber }}</span>
272+
<span class="badge">{{ collector.countParameters()|number_format(0, '.', ',') }}</span>
265273
</h3>
266274

267275
<div class="tab-content">
268276
<table>
269277
<thead>
270278
<tr>
271-
<th>#</th>
272-
<th>Parameter name</th>
279+
<th>Name</th>
280+
<th>Value</th>
273281
</tr>
274282
</thead>
275-
<tbody>
283+
<tbody>
276284
{% for parameterName, parameterValue in collector.getParameters() %}
277285
<tr>
278-
<td>{{ loop.index }}</td>
279286
<td>{{ parameterName }}</td>
287+
<td>{{ collector.dumpParameterValue(parameterValue) }}</td>
280288
</tr>
281289
{% endfor %}
282290
</tbody>

0 commit comments

Comments
 (0)