From 5f03d71838b3967f54c9558307be5e6f386dbce3 Mon Sep 17 00:00:00 2001 From: Peter Dietrich Date: Sat, 8 Apr 2017 13:29:48 +0200 Subject: [PATCH 1/3] Add helpful remarks on custom DataCollector When creating my own data colletor, I was not clear on how to exactly collect my data (unrelated to request/response) Here are two remarks that would have helped me a lot by the time * collect is only called once to "pick-up, not "gather" * how/where to store and access data that is not related to request/response --- profiler/data_collector.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 6c37816a81c..89e0d93c08c 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -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 @@ -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 From d80da02d5b80a702e64aed1cb48f0f5dc324570d Mon Sep 17 00:00:00 2001 From: Peter Dietrich Date: Sat, 8 Apr 2017 15:52:55 +0200 Subject: [PATCH 2/3] grammar fix "make accessible to" instead of "for" --- profiler/data_collector.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 89e0d93c08c..75ab5b2d423 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -78,7 +78,7 @@ 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. + If the data that is not directly related to the request or response, you need to make the data accessible to your DataCollector. This can be achieved by injecting the service into your DataCollector. From 06171740d0318dc8a59fb1154df60f0f5050e5c0 Mon Sep 17 00:00:00 2001 From: Peter Dietrich Date: Thu, 13 Apr 2017 12:43:33 +0200 Subject: [PATCH 3/3] Updated according to remarks by @xabbuh --- profiler/data_collector.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 75ab5b2d423..5204957795f 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -79,8 +79,7 @@ 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 to your DataCollector. - This can be achieved by injecting the service into your DataCollector. - + This can be achieved by injecting the service that holds the information you intend to profile into your DataCollector. .. caution::