@@ -414,3 +414,67 @@ configuration, and tag it with ``data_collector``:
414
414
;
415
415
416
416
.. _data collectors : http://api.symfony-reloaded.org/PR3/index.html?q=DataCollector
417
+
418
+ Adding Web Profiler Templates
419
+ -----------------------------
420
+
421
+ When you want to display the data collected by your Data Collector in the
422
+ web debug toolbar and the web profiler you have to create templates for it.
423
+
424
+ If you want to display the data in the web debug toolbar create the template
425
+ ``YourBundle/Resources/views/Profiler/mydata_bar.php ``:
426
+
427
+ <?php echo $data->getSummary() ?>
428
+
429
+ For more detailed data you will want to create the two web profiler templates:
430
+
431
+ * The menu template ``YourBundle/Resources/views/Profiler/mydata_menu.php ``:
432
+
433
+ <div class="count"><?php echo $data->getCount() ?></div>
434
+ <img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" alt="" src="<?php echo $view->get('assets')->getUrl('bundles/webprofiler/images/db.png') ?>" />
435
+ My Data
436
+
437
+ * The panel template ``YourBundle/Resources/views/Profiler/mydata_panel.php ``:
438
+
439
+ <h2>My Data Details</h2>
440
+
441
+ <ul class="alt">
442
+ <?php foreach($data->getDetails() as $i => $detail): ?>
443
+ <li class="<?php echo $i % 2 ? 'odd' : 'even' ?>">
444
+ <?php echo $detail ?>
445
+ </li>
446
+ <?php endforeach; ?>
447
+ </ul>
448
+
449
+ .. note ::
450
+ ``$data is an instance of your Data Collector class.
451
+
452
+ The next step is to let the web profiler know about your templates:
453
+
454
+ .. configuration-block::
455
+
456
+ .. code-block:: yaml
457
+
458
+ webprofiler.config:
459
+ toolbar: true
460
+ intercept_redirects: true
461
+ templates:
462
+ mydata: YourBundle:Profiler:mydata.php
463
+
464
+ .. code-block:: xml
465
+
466
+ <webprofiler:config toolbar="true" intercept-redirects="true">
467
+ <webprofiler:templates
468
+ mydata="YourBundle:Profiler:mydata.php"
469
+ />
470
+ </webprofiler:config>
471
+
472
+ .. code-block:: php
473
+
474
+ $container->loadFromExtension('webprofiler', 'config', array(
475
+ 'toolbar' => true,
476
+ 'intercept-redirects' => true,
477
+ 'templates' => array(
478
+ 'mydata' => 'YourBundle:Profiler:mydata.php',
479
+ ),
480
+ ));
0 commit comments