Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44a070c

Browse filesBrowse files
sncfabpot
authored andcommitted
Added documentation about web profiler templates
1 parent adef350 commit 44a070c
Copy full SHA for 44a070c

File tree

Expand file treeCollapse file tree

1 file changed

+64
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+64
-0
lines changed

‎guides/internals/profiler.rst

Copy file name to clipboardExpand all lines: guides/internals/profiler.rst
+64Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,67 @@ configuration, and tag it with ``data_collector``:
414414
;
415415
416416
.. _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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.