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 c4d4fb1

Browse filesBrowse files
committed
updated documentation
1 parent 44a070c commit c4d4fb1
Copy full SHA for c4d4fb1

File tree

Expand file treeCollapse file tree

1 file changed

+25
-26
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-26
lines changed

‎guides/internals/profiler.rst

Copy file name to clipboardExpand all lines: guides/internals/profiler.rst
+25-26Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -418,38 +418,37 @@ configuration, and tag it with ``data_collector``:
418418
Adding Web Profiler Templates
419419
-----------------------------
420420

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.
421+
When you want to display the data collected by your Data Collector in the web
422+
debug toolbar or the web profiler, create a Twig template following this
423+
skeleton:
423424

424-
If you want to display the data in the web debug toolbar create the template
425-
``YourBundle/Resources/views/Profiler/mydata_bar.php``:
425+
.. code-block:: jinja
426426
427-
<?php echo $data->getSummary() ?>
427+
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
428428
429-
For more detailed data you will want to create the two web profiler templates:
429+
{% block toolbar %}
430+
{# the web debug toolbar content #}
431+
{% endblock %}
430432
431-
* The menu template ``YourBundle/Resources/views/Profiler/mydata_menu.php``:
433+
{% block head %}
434+
{# if the web profiler panel needs some specific JS or CSS files #}
435+
{% endblock %}
432436
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
437+
{% block menu %}
438+
{# the menu content #}
439+
{% endblock %}
436440
437-
* The panel template ``YourBundle/Resources/views/Profiler/mydata_panel.php``:
441+
{% block panel %}
442+
{# the panel content #}
443+
{% endblock %}
438444
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>
445+
Each block is optional. The ``toolbar`` block is used for the web debug
446+
toolbar and ``menu`` and ``panel`` are used to add a panel to the web
447+
profiler.
448448

449-
.. note::
450-
``$data is an instance of your Data Collector class.
449+
All blocks have access to the ``collector`` object.
451450

452-
The next step is to let the web profiler know about your templates:
451+
To enable the template, register it in your configuration:
453452

454453
.. configuration-block::
455454

@@ -459,13 +458,13 @@ The next step is to let the web profiler know about your templates:
459458
toolbar: true
460459
intercept_redirects: true
461460
templates:
462-
mydata: YourBundle:Profiler:mydata.php
461+
mydata: YourBundle:Profiler:mydata
463462
464463
.. code-block:: xml
465464
466465
<webprofiler:config toolbar="true" intercept-redirects="true">
467466
<webprofiler:templates
468-
mydata="YourBundle:Profiler:mydata.php"
467+
mydata="YourBundle:Profiler:mydata"
469468
/>
470469
</webprofiler:config>
471470
@@ -475,6 +474,6 @@ The next step is to let the web profiler know about your templates:
475474
'toolbar' => true,
476475
'intercept-redirects' => true,
477476
'templates' => array(
478-
'mydata' => 'YourBundle:Profiler:mydata.php',
477+
'mydata' => 'YourBundle:Profiler:mydata',
479478
),
480479
));

0 commit comments

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