From 2270a2cb208fda8eb18f3595cb6d823a625d0ddf Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Sun, 1 Sep 2013 21:56:50 +0200 Subject: [PATCH] data collector example --- .../DataCollector/SomeDataCollector.php | 35 +++++++++++++++++++ .../DemoBundle/Resources/config/services.xml | 5 +++ .../views/Collector/messages.html.twig | 35 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 src/Acme/DemoBundle/DataCollector/SomeDataCollector.php create mode 100644 src/Acme/DemoBundle/Resources/views/Collector/messages.html.twig diff --git a/src/Acme/DemoBundle/DataCollector/SomeDataCollector.php b/src/Acme/DemoBundle/DataCollector/SomeDataCollector.php new file mode 100644 index 0000000000..c4fd2ee510 --- /dev/null +++ b/src/Acme/DemoBundle/DataCollector/SomeDataCollector.php @@ -0,0 +1,35 @@ +service = $service; + } + + /** + * {@inheritdoc} + */ + public function collect(Request $request, Response $response, \Exception $exception = null) + { + $this->data = $this->service->getMessages(); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'some_data_collector'; + } +} \ No newline at end of file diff --git a/src/Acme/DemoBundle/Resources/config/services.xml b/src/Acme/DemoBundle/Resources/config/services.xml index b761e36dba..8218c926c8 100644 --- a/src/Acme/DemoBundle/Resources/config/services.xml +++ b/src/Acme/DemoBundle/Resources/config/services.xml @@ -16,5 +16,10 @@ + + + + + diff --git a/src/Acme/DemoBundle/Resources/views/Collector/messages.html.twig b/src/Acme/DemoBundle/Resources/views/Collector/messages.html.twig new file mode 100644 index 0000000000..9e363fdd98 --- /dev/null +++ b/src/Acme/DemoBundle/Resources/views/Collector/messages.html.twig @@ -0,0 +1,35 @@ +{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %} + +{% block toolbar %} + {% set icon %} + Some Service + {{ collector.data|length }} + {% endset %} + {% set text %} +
{{ collector.data|length }}
+ {% endset %} + {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %} +{% endblock %} + +{% block head %} + {{ parent() }} +{% endblock %} + +{% block menu %} + + Some Service + Some Service + + {{ collector.data|length }} + + +{% endblock %} + +{% block panel %} +

Some Service

+ {% for message in collector.data %} +
{{ message }}
+ {% else %} +

No messages

+ {% endfor %} +{% endblock %} \ No newline at end of file