Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05773c2

Browse files
javiereguiluzfabpot
authored andcommitted
Redesigned the Symfony Profiler
1 parent 0edcc2e commit 05773c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2547
-1767
lines changed

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ public function getMacroCount()
7474
public function getHtmlCallGraph()
7575
{
7676
$dumper = new \Twig_Profiler_Dumper_Html();
77-
78-
return new \Twig_Markup($dumper->dump($this->getProfile()), 'UTF-8');
77+
$dump = $dumper->dump($this->getProfile());
78+
79+
// needed to remove the hardcoded CSS styles
80+
$dump = str_replace(array(
81+
'<span style="background-color: #ffd">',
82+
'<span style="color: #d44">',
83+
'<span style="background-color: #dfd">',
84+
), array(
85+
'<span class="status-warning">',
86+
'<span class="status-error">',
87+
'<span class="status-success">',
88+
), $dump);
89+
90+
return new \Twig_Markup($dump, 'UTF-8');
7991
}
8092

8193
public function getProfile()
Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

33
{% block toolbar %}
4-
{% set dumps_count = collector.dumpsCount %}
5-
6-
{% if dumps_count %}
4+
{% if collector.dumpsCount %}
75
{% set icon %}
8-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="24" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
9-
<path fill="#AAAAAA" d="M12,22.6c-5.8,0-10.5-4.7-10.5-10.5C1.5,6.3,6.2,1.5,12,1.5s10.5,4.7,10.5,10.5C22.5,17.9,17.8,22.6,12,22.6z M12,4.5c-4.2,0-7.5,3.4-7.5,7.5c0,4.2,3.4,7.5,7.5,7.5s7.5-3.4,7.5-7.5C19.5,7.9,16.2,4.5,12,4.5z"/>
10-
<path fill="#AAAAAA" d="M12,9.1c-0.8,0-1.5-0.7-1.5-1.5v-6c0-0.8,0.7-1.5,1.5-1.5s1.5,0.7,1.5,1.5v6C13.5,8.4,12.8,9.1,12,9.1zM13.5,22.4v-6c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5v6c0,0.8,0.7,1.5,1.5,1.5S13.5,23.2,13.5,22.4z M23.9,12c0-0.8-0.7-1.5-1.5-1.5h-6c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5h6C23.2,13.5,23.9,12.8,23.9,12z M9.1,12c0-0.8-0.7-1.5-1.5-1.5h-6c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5h6C8.4,13.5,9.1,12.8,9.1,12z"/>
11-
</svg>
12-
<span class="sf-toolbar-value">{{ dumps_count }}</span>
6+
{{ include('@Debug/Profiler/icon.svg') }}
7+
<span class="sf-toolbar-value">{{ collector.dumpsCount }}</span>
138
{% endset %}
149

1510
{% set text %}
@@ -28,6 +23,7 @@
2823
{% endif %}
2924
</span>
3025
<span class="sf-toolbar-file-line">line {{ dump.line }}</span>
26+
3127
{{ dump.data|raw }}
3228
</div>
3329
{% endfor %}
@@ -39,42 +35,18 @@
3935
{% endblock %}
4036

4137
{% block menu %}
42-
<span class="label">
43-
<span class="icon">
44-
{{- "" -}}
45-
<svg width="28" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve"><path fill="#3F3F3F" d="M28 13h-1.1C26.5 6.6 21.4 1.5 15 1.1V0h-2v1.1C6.6 1.5 1.5 6.6 1.1 13H0v2h1.1C1.5 21.4 6.6 26.5 13 26.9 V28h2v-1.1c6.4-0.5 11.5-5.6 11.9-11.9H28V13z M15 24.9V19h-2v5.9c-5.3-0.5-9.5-4.7-9.9-9.9H9v-2H3.1C3.5 7.7 7.7 3.5 13 3.1V9h2 V3.1c5.3 0.5 9.5 4.7 9.9 9.9H19v2h5.9C24.5 20.3 20.3 24.5 15 24.9z"/></svg>
46-
{{- "" -}}
47-
</span>
48-
<strong>dump()</strong>
49-
<span class="count">
50-
<span>{{ collector.dumpsCount }}</span>
51-
</span>
38+
<span class="label {{ collector.dumpsCount == 0 ? 'disabled' }}">
39+
<span class="icon">{{ include('@Debug/Profiler/icon.svg') }}</span>
40+
<strong>Debug</strong>
5241
</span>
5342
{% endblock %}
5443

5544
{% block panel %}
56-
<h2>dump()</h2>
45+
<h2>Dumped Contents</h2>
5746

58-
<style>
59-
li.sf-dump {
60-
list-style-type: disc;
61-
}
62-
.sf-dump ol>li {
63-
padding: 0;
64-
}
65-
.sf-dump a {
66-
cursor: pointer;
67-
}
68-
.sf-dump-compact {
69-
display: none;
70-
}
71-
</style>
72-
73-
{% if collector.dumpsCount %}
74-
<ul class="alt">
75-
{% for dump in collector.getDumps('html') %}
76-
<li class="sf-dump sf-reset">
77-
in
47+
{% for dump in collector.getDumps('html') %}
48+
<div class="sf-dump sf-reset">
49+
<h3>In
7850
{% if dump.line %}
7951
{% set link = dump.file|file_link(dump.line) %}
8052
{% if link %}
@@ -85,19 +57,22 @@
8557
{% else %}
8658
{{ dump.name }}
8759
{% endif %}
88-
line {{ dump.line }}:
89-
<a onclick="var s = this.nextElementSibling; if ('sf-dump-compact' == s.className) {this.innerHTML = '&#9660;'; s.className = 'sf-dump-expanded';} else {this.innerHTML = '&#9654;'; s.className = 'sf-dump-compact';}">&#9654;</a>
90-
<span class="sf-dump-compact">
91-
{% if dump.fileExcerpt %}{{ dump.fileExcerpt|raw }}{% else %}{{ dump.file|file_excerpt(dump.line) }}{% endif %}
92-
</span>
60+
<small>line {{ dump.line }}</small>
9361

94-
{{ dump.data|raw }}
95-
</li>
96-
{% endfor %}
97-
</ul>
62+
<a class="text-small sf-toggle" data-toggle-selector="#sf-trace-{{ loop.index0 }}" data-toggle-alt-content="Hide code">Show code</a>
63+
</h3>
64+
65+
<div class="sf-dump-compact hidden" id="sf-trace-{{ loop.index0 }}">
66+
<div class="trace">
67+
{{ dump.fileExcerpt ? dump.fileExcerpt|raw : dump.file|file_excerpt(dump.line) }}
68+
</div>
69+
</div>
70+
71+
{{ dump.data|raw }}
72+
</div>
9873
{% else %}
99-
<p>
100-
<em>No dumped variable</em>
101-
</p>
102-
{% endif %}
74+
<div class="empty">
75+
<p>No content was dumped.</p>
76+
</div>
77+
{% endfor %}
10378
{% endblock %}
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

3+
{% block page_title 'Security' %}
4+
35
{% block toolbar %}
46
{% if collector.tokenClass %}
57
{% set is_authenticated = collector.enabled and collector.authenticated %}
@@ -9,9 +11,7 @@
911
{% endif %}
1012

1113
{% set icon %}
12-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="24" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
13-
<path fill="#AAAAAA" d="M21,20.4V22H3v-1.6c0-3.7,2.4-6.9,5.8-8c-1.7-1.1-2.9-3-2.9-5.2c0-3.4,2.7-6.1,6.1-6.1s6.1,2.7,6.1,6.1c0,2.2-1.2,4.1-2.9,5.2C18.6,13.5,21,16.7,21,20.4z"/>
14-
</svg>
14+
{{ include('@Security/Collector/icon.svg') }}
1515
<span class="sf-toolbar-value">{{ collector.user|default('n/a') }}</span>
1616
{% endset %}
1717

@@ -21,10 +21,12 @@
2121
<b>Logged in as</b>
2222
<span>{{ collector.user }}</span>
2323
</div>
24+
2425
<div class="sf-toolbar-info-piece">
2526
<b>Authenticated</b>
2627
<span class="sf-toolbar-status sf-toolbar-status-{{ is_authenticated ? 'green' : 'red' }}">{{ is_authenticated ? 'Yes' : 'No' }}</span>
2728
</div>
29+
2830
{% if collector.tokenClass != null %}
2931
<div class="sf-toolbar-info-piece">
3032
<b>Token class</b>
@@ -46,54 +48,69 @@
4648
{% endblock %}
4749

4850
{% block menu %}
49-
<span class="label">
50-
<span class="icon"><svg width="42" height="30" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 42 30" enable-background="new 0 0 42 30" xml:space="preserve"><g><path fill="#3F3F3F" d="M16.1 15.3c0-0.5 0-0.8 0-1.2c0.2-0.1 0.6-0.8 0.7-1.4c0.2 0 0.4-0.2 0.5-0.8c0-0.4-0.1-0.5-0.2-0.6 c0.3-0.8 0.8-3.4-1.1-3.7C15.7 7.2 15.2 7 14.6 7c-2.6 0-2.9 2-2.4 4.2c-0.1 0.1-0.3 0.3-0.2 0.6c0.1 0.7 0.3 0.8 0.5 0.8 c0.1 0.6 0.5 1.3 0.7 1.4c0 0.4 0 0.8 0 1.2c-0.5 1.4-4 1-4.2 3.7h11.2C20.1 16.3 16.6 16.7 16.1 15.3z"/><path fill="#3F3F3F" d="M28.3 10.2c-0.2 0-0.5 0.1-0.7 0.2c-0.2 0.1-0.4 0.3-0.6 0.6c-0.2 0.3-0.4 0.6-0.5 1s-0.2 0.7-0.2 1.1 c0 0.5 0.1 0.9 0.4 1.2s0.5 0.4 0.8 0.4c0.2 0 0.4-0.1 0.7-0.2c0.2-0.1 0.5-0.3 0.7-0.6s0.4-0.6 0.5-1c0.1-0.4 0.2-0.8 0.2-1.2 c0-0.5-0.1-0.9-0.4-1.2C29 10.3 28.7 10.2 28.3 10.2z"/><path fill="#3F3F3F" d="M34 4H7C6.4 4 6 4.4 6 5v19c0 0.6 0.4 1 1 1h5v-1c-0.6 0-1-0.4-1-1c0-0.6 0.4-1 1-1h2c0.6 0 1 0.4 1 1 c0 0.6-0.4 1-1 1v1h13v-1c-0.6 0-1-0.4-1-1c0-0.6 0.4-1 1-1h2c0.6 0 1 0.4 1 1c0 0.6-0.4 1-1 1v1h5c0.6 0 1-0.4 1-1V5 C35 4.4 34.6 4 34 4z M21 19c0 0.6-0.4 1-1 1H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.8 0.3 1.6 0.5 2.5 0.5c1 0 1.8-0.2 2.5-0.5c0.7-0.3 1.2-0.7 1.5-1.2h1 C33.7 15.8 33.4 16.2 32.9 16.6z"/></g></svg></span>
51-
<strong>Security</strong>
52-
</span>
51+
<span class="label {{ not collector.enabled or not collector.tokenClass ? 'disabled' }}">
52+
<span class="icon">{{ include('@Security/Collector/icon.svg') }}</span>
53+
<strong>Security</strong>
54+
</span>
5355
{% endblock %}
5456

5557
{% block panel %}
56-
<h2>Security</h2>
58+
<h2>Security Token</h2>
59+
5760
{% if collector.tokenClass %}
61+
<div class="metrics">
62+
<div class="metric">
63+
<span class="value">{{ collector.user == 'anon.' ? 'Anonymous' : collector.user }}</span>
64+
<span class="label">Username</span>
65+
</div>
66+
67+
<div class="metric">
68+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.authenticated ? 'yes' : 'no') ~ '.svg') }}</span>
69+
<span class="label">Authenticated</span>
70+
</div>
71+
</div>
72+
5873
<table>
59-
<tr>
60-
<th>Username</th>
61-
<td>{{ collector.user }}</td>
62-
</tr>
63-
<tr>
64-
<th>Authenticated?</th>
65-
<td>
66-
{% if collector.authenticated %}
67-
yes
68-
{% else %}
69-
no {% if not collector.roles|length %}<em>(probably because the user has no roles)</em>{% endif %}
70-
{% endif %}
71-
</td>
72-
</tr>
73-
<tr>
74-
<th>Roles</th>
75-
<td>{{ collector.roles|yaml_encode }}</td>
76-
</tr>
77-
{% if collector.supportsRoleHierarchy %}
78-
<tr>
79-
<th>Inherited Roles</th>
80-
<td>{{ collector.inheritedRoles|yaml_encode }}</td>
81-
</tr>
82-
{% endif %}
83-
{% if collector.tokenClass != null %}
84-
<tr>
85-
<th>Token class</th>
86-
<td>{{ collector.tokenClass }}</td>
87-
</tr>
88-
{% endif %}
74+
<thead>
75+
<tr>
76+
<th scope="col" class="key">Property</th>
77+
<th scope="col">Value</th>
78+
</tr>
79+
</thead>
80+
<tbody>
81+
<tr>
82+
<th>Roles</th>
83+
<td>
84+
{{ collector.roles is empty ? 'none' : collector.roles|yaml_encode }}
85+
86+
{% if not collector.authenticated and collector.roles is empty %}
87+
<p class="help">User is not authenticated probably because they have no roles.</p>
88+
{% endif %}
89+
</td>
90+
</tr>
91+
92+
{% if collector.supportsRoleHierarchy %}
93+
<tr>
94+
<th>Inherited Roles</th>
95+
<td>{{ collector.inheritedRoles is empty ? 'none' : collector.inheritedRoles|yaml_encode }}</td>
96+
</tr>
97+
{% endif %}
98+
99+
{% if collector.tokenClass %}
100+
<tr>
101+
<th>Token class</th>
102+
<td>{{ collector.tokenClass }}</td>
103+
</tr>
104+
{% endif %}
105+
</tbody>
89106
</table>
90107
{% elseif collector.enabled %}
91-
<p>
92-
<em>No token</em>
93-
</p>
108+
<div class="empty">
109+
<p>There is no security token.</p>
110+
</div>
94111
{% else %}
95-
<p>
96-
<em>The security component is disabled</em>
97-
</p>
112+
<div class="empty">
113+
<p>The security component is disabled.</p>
114+
</div>
98115
{% endif %}
99116
{% endblock %}

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function panelAction(Request $request, $token)
112112
'request' => $request,
113113
'templates' => $this->getTemplateManager()->getTemplates($profile),
114114
'is_ajax' => $request->isXmlHttpRequest(),
115+
'profiler_markup_version' => 2, // 1 = original profiler, 2 = Symfony 2.8+ profiler
115116
)), 200, array('Content-Type' => 'text/html'));
116117
}
117118

0 commit comments

Comments
 (0)