Skip to content

Commit afb86c7

Browse files
committed
Tweaks and fixes
1 parent caa9eaf commit afb86c7

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

cookbook/profiler/data_collector.rst

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ properties.
4646
store objects that cannot be serialized (like PDO objects), or you need
4747
to provide your own ``serialize()`` method.
4848

49-
Most of the times, it is convenient to extend
49+
Most of the time, it is convenient to extend
5050
:class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector` and
5151
populate the ``$this->data`` property (it takes care of serializing the
5252
``$this->data`` property)::
5353

5454
// src/AppBundle/DataCollector/MyCollector.php
55+
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
56+
5557
class MyCollector extends DataCollector
5658
{
5759
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
7779
Enabling Custom Data Collectors
7880
-------------------------------
7981

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``:
8284

8385
.. configuration-block::
8486

@@ -88,21 +90,33 @@ and tag it with ``data_collector``:
8890
services:
8991
app.my_collector:
9092
class: AppBundle\DataCollector\MyCollector
93+
public: false
9194
tags:
9295
- { name: data_collector }
9396
9497
.. code-block:: xml
9598
9699
<!-- 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>
100113
101114
.. code-block:: php
102115
103116
// app/config/services.php
104117
$container
105118
->register('app.my_collector', 'AppBundle\DataCollector\MyCollector')
119+
->setPublic(false)
106120
->addTag('data_collector')
107121
;
108122
@@ -117,9 +131,9 @@ In the simplest case, you just want to display the information in the toolbar
117131
without providing a profiler panel. This requires to define the ``toolbar``
118132
block and set the value of two variables called ``icon`` and ``text``:
119133

120-
.. code-block:: jinja
134+
.. code-block:: html+jinja
121135

122-
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
136+
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
123137

124138
{% block toolbar %}
125139
{% set icon %}
@@ -167,9 +181,9 @@ block and set the value of two variables called ``icon`` and ``text``:
167181
You are encouraged to use the latter technique for your own toolbar panels.
168182

169183
If the toolbar panel includes extended web profiler information, the Twig template
170-
must also define other blocks:
184+
must also define additional blocks:
171185

172-
.. code-block:: jinja
186+
.. code-block:: html+jinja
173187

174188
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
175189

@@ -186,14 +200,14 @@ must also define other blocks:
186200
{% endset %}
187201

188202
{# 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
190204
value, you can omit the 'link' parameter entirely #}
191205
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true }) }}
192206
{% endblock %}
193207

194208
{% 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 #}
197211
{% endblock %}
198212

199213
{% block menu %}
@@ -228,20 +242,34 @@ the ``data_collector`` tag in your service configuration:
228242
app.my_collector:
229243
class: AppBundle\DataCollector\MyCollector
230244
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
232250
233251
.. code-block:: xml
234252
235253
<!-- 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>
239266
240267
.. code-block:: php
241268
242269
// app/config/services.php
243270
$container
244271
->register('app.my_collector', 'AppBundle\DataCollector\MyCollector')
272+
->setPublic(false)
245273
->addTag('data_collector', array(
246274
'template' => 'data_collector/template.html.twig',
247275
'id' => 'app.my_collector',

0 commit comments

Comments
 (0)