Skip to content

Commit 29522b3

Browse files
xosofoxxabbuh
authored andcommitted
Add helpful remarks on custom DataCollector
1 parent 984eeb0 commit 29522b3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

profiler/data_collector.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ The
3030
:method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::collect`
3131
method is responsible for storing the collected data in local properties.
3232

33+
.. caution::
34+
35+
The :method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::collect` method is only called once.
36+
It is not used to "gather" data but is there to "pick up" the data that has been stored by your service.
37+
3338
Most of the time, it is convenient to extend
3439
:class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector` and
3540
populate the ``$this->data`` property (it takes care of serializing the
@@ -71,6 +76,11 @@ collects the method and accepted content types from the request::
7176

7277
The getters are added to give the template access to the collected information.
7378

79+
.. caution::
80+
81+
If the data that is not directly related to the request or response, you need to make the data accessible to your DataCollector.
82+
This can be achieved by injecting the service that holds the information you intend to profile into your DataCollector.
83+
7484
.. caution::
7585

7686
As the profiler serializes data collector instances, you should not

0 commit comments

Comments
 (0)