Skip to content

Add helpful remarks on custom DataCollector #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions profiler/data_collector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ The
:method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::collect`
method is responsible for storing the collected data in local properties.

.. caution::

The :method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::collect` method is only called once.
It is not used to "gather" data but is there to "pick up" the data that has been stored by your service.

Most of the time, it is convenient to extend
:class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector` and
populate the ``$this->data`` property (it takes care of serializing the
Expand Down Expand Up @@ -71,6 +76,12 @@ collects the method and accepted content types from the request::

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

.. caution::

If the data that is not directly related to the request or response, you need to make the data accessible for your DataCollector.
This can be achieved by injecting the service into your DataCollector.


.. caution::

As the profiler serializes data collector instances, you should not
Expand Down