Skip to content

Commit 9f8f97a

Browse files
authored
Merge pull request #1 from Xosofox/datacollector-remarks
Add helpful remarks on custom DataCollector
2 parents e47090e + 5f03d71 commit 9f8f97a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

profiler/data_collector.rst

Lines changed: 11 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,12 @@ 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 for your DataCollector.
82+
This can be achieved by injecting the service into your DataCollector.
83+
84+
7485
.. caution::
7586

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

0 commit comments

Comments
 (0)