@@ -46,12 +46,14 @@ properties.
46
46
store objects that cannot be serialized (like PDO objects), or you need
47
47
to provide your own ``serialize() `` method.
48
48
49
- Most of the times , it is convenient to extend
49
+ Most of the time , it is convenient to extend
50
50
:class: `Symfony\\ Component\\ HttpKernel\\ DataCollector\\ DataCollector ` and
51
51
populate the ``$this->data `` property (it takes care of serializing the
52
52
``$this->data `` property)::
53
53
54
54
// src/AppBundle/DataCollector/MyCollector.php
55
+ use Symfony\Component\HttpKernel\DataCollector\DataCollector;
56
+
55
57
class MyCollector extends DataCollector
56
58
{
57
59
public function collect(Request $request, Response $response, \Exception $exception = null)
@@ -77,8 +79,8 @@ populate the ``$this->data`` property (it takes care of serializing the
77
79
Enabling Custom Data Collectors
78
80
-------------------------------
79
81
80
- To enable a data collector, define it as a regular service in your application
81
- and tag it with ``data_collector ``:
82
+ To enable a data collector, define it as a regular service and tag it with
83
+ ``data_collector ``:
82
84
83
85
.. configuration-block ::
84
86
@@ -88,21 +90,33 @@ and tag it with ``data_collector``:
88
90
services :
89
91
app.my_collector :
90
92
class : AppBundle\DataCollector\MyCollector
93
+ public : false
91
94
tags :
92
95
- { name: data_collector }
93
96
94
97
.. code-block :: xml
95
98
96
99
<!-- app/config/services.xml -->
97
- <service id =" app.my_collector" class =" AppBundle\DataCollector\MyCollector" >
98
- <tag name =" data_collector" />
99
- </service >
100
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
101
+ <container xmlns =" http://symfony.com/schema/dic/services"
102
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
103
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
104
+ http://symfony.com/schema/dic/services/services-1.0.xsd"
105
+ >
106
+ <services >
107
+ <service id =" app.my_collector" class =" AppBundle\DataCollector\MyCollector"
108
+ public =" false" >
109
+ <tag name =" data_collector" />
110
+ </service >
111
+ </services >
112
+ </container >
100
113
101
114
.. code-block :: php
102
115
103
116
// app/config/services.php
104
117
$container
105
118
->register('app.my_collector', 'AppBundle\DataCollector\MyCollector')
119
+ ->setPublic(false)
106
120
->addTag('data_collector')
107
121
;
108
122
@@ -117,9 +131,9 @@ In the simplest case, you just want to display the information in the toolbar
117
131
without providing a profiler panel. This requires to define the ``toolbar ``
118
132
block and set the value of two variables called ``icon `` and ``text ``:
119
133
120
- .. code-block :: jinja
134
+ .. code-block :: html+ jinja
121
135
122
- {% extends '@WebProfiler/ Profiler/ layout.html.twig' %}
136
+ {% extends 'WebProfilerBundle : Profiler: layout.html.twig' %}
123
137
124
138
{% block toolbar %}
125
139
{% set icon %}
@@ -167,9 +181,9 @@ block and set the value of two variables called ``icon`` and ``text``:
167
181
You are encouraged to use the latter technique for your own toolbar panels.
168
182
169
183
If the toolbar panel includes extended web profiler information, the Twig template
170
- must also define other blocks:
184
+ must also define additional blocks:
171
185
172
- .. code-block :: jinja
186
+ .. code-block :: html+ jinja
173
187
174
188
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
175
189
@@ -186,14 +200,14 @@ must also define other blocks:
186
200
{% endset %}
187
201
188
202
{# the 'link' value is now set to 'true', which allows the user to click
189
- on it to access to the web profiler panel. Since 'true' is the default
203
+ on it to access the web profiler panel. Since 'true' is the default
190
204
value, you can omit the 'link' parameter entirely #}
191
205
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true }) }}
192
206
{% endblock %}
193
207
194
208
{% block head %}
195
- {# Optional, here you can link to or define your own CSS and JS contents #}
196
- {# Use {{ parent() }} to keep the default styles #}
209
+ {# Optional, you can here link to or define your own CSS and JS contents #}
210
+ {# {{ parent() }} to keep the default styles #}
197
211
{% endblock %}
198
212
199
213
{% block menu %}
@@ -228,20 +242,34 @@ the ``data_collector`` tag in your service configuration:
228
242
app.my_collector :
229
243
class : AppBundle\DataCollector\MyCollector
230
244
tags :
231
- - { name: data_collector, template: 'data_collector/template.html.twig', id: 'app.my_collector' }
245
+ -
246
+ name : data_collector
247
+ template : ' data_collector/template.html.twig'
248
+ id : ' app.my_collector'
249
+ public : false
232
250
233
251
.. code-block :: xml
234
252
235
253
<!-- app/config/services.xml -->
236
- <service id =" app.my_collector" class =" AppBundle\DataCollector\MyCollector" >
237
- <tag name =" data_collector" template =" data_collector/template.html.twig" id =" app.my_collector" />
238
- </service >
254
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
255
+ <container xmlns =" http://symfony.com/schema/dic/services"
256
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
257
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
258
+ http://symfony.com/schema/dic/services/services-1.0.xsd"
259
+ >
260
+ <services >
261
+ <service id =" app.my_collector" class =" AppBundle\DataCollector\MyCollector" >
262
+ <tag name =" data_collector" template =" data_collector/template.html.twig" id =" app.my_collector" public =" false" />
263
+ </service >
264
+ </services >
265
+ </container >
239
266
240
267
.. code-block :: php
241
268
242
269
// app/config/services.php
243
270
$container
244
271
->register('app.my_collector', 'AppBundle\DataCollector\MyCollector')
272
+ ->setPublic(false)
245
273
->addTag('data_collector', array(
246
274
'template' => 'data_collector/template.html.twig',
247
275
'id' => 'app.my_collector',
0 commit comments