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 0a1b284

Browse filesBrowse files
committed
[WebProfiler] [HttpKernel] profile redirections
closes #17501. The profiler stores the current request attributes in a current session when a `RedirectionResponse` is returned. So the next request profile will inherit the previous request attributes. The main profiler layout displays a shortcut to a previous redirection profile, along with some useful informations. The web debug toolbar shows a notifying icon, meaning a shortcut to a redirection profile is available in the request toolbar panel.
1 parent 06eb52c commit 0a1b284
Copy full SHA for 0a1b284

File tree

Expand file treeCollapse file tree

7 files changed

+224
-86
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+224
-86
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig
+65-33Lines changed: 65 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,72 @@
22

33
{% block toolbar %}
44
{% set request_handler %}
5-
{% if collector.controller.class is defined %}
6-
{% set link = collector.controller.file|file_link(collector.controller.line) %}
7-
{% if link %}<a href="{{ link }}" title="{{ collector.controller.file }}">{% else %}<span>{% endif %}
8-
9-
{{ collector.controller.class|abbr_class|striptags }}
10-
11-
{%- if collector.controller.method -%}
12-
&nbsp;::&nbsp;{{ collector.controller.method }}
13-
{%- endif -%}
14-
15-
{% if link %}</a>{% else %}</span>{% endif %}
16-
{% else %}
17-
<span>{{ collector.controller }}</span>
18-
{% endif %}
5+
{% import _self as helper %}
6+
{{ helper.set_handler(collector.controller) }}
197
{% endset %}
208

9+
{% if collector.redirect %}
10+
{% set redirect_handler %}
11+
{% import _self as helper %}
12+
{{ helper.set_handler(collector.redirect.controller, collector.redirect.route, 'GET' != collector.redirect.method ? collector.redirect.method) }}
13+
{% endset %}
14+
{% endif %}
15+
2116
{% set request_status_code_color = (collector.statuscode >= 400) ? 'red' : (collector.statuscode >= 300) ? 'yellow' : 'green' %}
2217

2318
{% set icon %}
2419
<span class="sf-toolbar-status sf-toolbar-status-{{ request_status_code_color }}">{{ collector.statuscode }}</span>
2520
{% if collector.route %}
21+
{% if collector.redirect %}{{ include('@WebProfiler/Icon/redirect.svg') }}{% endif %}
2622
<span class="sf-toolbar-label">@</span>
2723
<span class="sf-toolbar-value sf-toolbar-info-piece-additional">{{ collector.route }}</span>
2824
{% endif %}
2925
{% endset %}
3026

3127
{% set text %}
32-
<div class="sf-toolbar-info-piece">
33-
<b>HTTP status</b>
34-
<span>{{ collector.statuscode }} {{ collector.statustext }}</span>
35-
</div>
28+
<div class="sf-toolbar-info-group">
29+
<div class="sf-toolbar-info-piece">
30+
<b>HTTP status</b>
31+
<span>{{ collector.statuscode }} {{ collector.statustext }}</span>
32+
</div>
3633

37-
<div class="sf-toolbar-info-piece">
38-
<b>Controller</b>
39-
<span>{{ request_handler }}</span>
40-
</div>
34+
<div class="sf-toolbar-info-piece">
35+
<b>Controller</b>
36+
<span>{{ request_handler }}</span>
37+
</div>
38+
39+
{% if collector.controller.class is defined -%}
40+
<div class="sf-toolbar-info-piece">
41+
<b>Controller class</b>
42+
<span>{{ collector.controller.class }}</span>
43+
</div>
44+
{%- endif %}
4145

42-
{% if collector.controller.class is defined %}
4346
<div class="sf-toolbar-info-piece">
44-
<b>Controller class</b>
45-
<span>{{ collector.controller.class }}</span>
47+
<b>Route name</b>
48+
<span>{{ collector.route|default('NONE') }}</span>
4649
</div>
47-
{% endif %}
4850

49-
<div class="sf-toolbar-info-piece">
50-
<b>Route name</b>
51-
<span>{{ collector.route|default('NONE') }}</span>
51+
<div class="sf-toolbar-info-piece">
52+
<b>Has session</b>
53+
<span>{% if collector.sessionmetadata|length %}yes{% else %}no{% endif %}</span>
54+
</div>
5255
</div>
5356

54-
<div class="sf-toolbar-info-piece">
55-
<b>Has session</b>
56-
<span>{% if collector.sessionmetadata|length %}yes{% else %}no{% endif %}</span>
57-
</div>
57+
{% if redirect_handler is defined -%}
58+
<div class="sf-toolbar-info-group">
59+
<div class="sf-toolbar-info-piece">
60+
<b>
61+
<span class="sf-toolbar-redirection-status sf-toolbar-status-yellow">{{ collector.redirect.status_code }}</span>
62+
Redirect from
63+
</b>
64+
<span>
65+
{{ redirect_handler }}
66+
(<a href="{{ path('_profiler', { token: collector.redirect.token }) }}">{{ collector.redirect.token }}</a>)
67+
</span>
68+
</div>
69+
</div>
70+
{% endif %}
5871
{% endset %}
5972

6073
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }}
@@ -224,3 +237,22 @@
224237
{% endif %}
225238
</div>
226239
{% endblock %}
240+
241+
{% macro set_handler(controller, route, method) %}
242+
{% if controller.class is defined -%}
243+
{%- if method|default(false) %}<span class="sf-toolbar-status sf-toolbar-redirection-method">{{ method }}</span>{% endif -%}
244+
{%- set link = controller.file|file_link(controller.line) %}
245+
{%- if link %}<a href="{{ link }}" title="{{ controller.file }}">{% else %}<span>{% endif %}
246+
247+
{%- if route|default(false) -%}
248+
@{{ route }}
249+
{%- else -%}
250+
{{- controller.class|abbr_class|striptags -}}
251+
{{- controller.method ? ' :: ' ~ controller.method -}}
252+
{%- endif -%}
253+
254+
{%- if link %}</a>{% else %}</span>{% endif %}
255+
{%- else -%}
256+
<span>{{ route|default(controller) }}</span>
257+
{%- endif %}
258+
{% endmacro %}
+10Lines changed: 10 additions & 0 deletions
Loading

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@
1919
{% endif %}
2020
</h2>
2121

22+
{% if profile.collectors.request is defined and profile.collectors.request.redirect -%}
23+
{%- set redirect = profile.collectors.request.redirect -%}
24+
{%- set controller = redirect.controller -%}
25+
{%- set redirect_route = '@' ~ redirect.route %}
26+
<dl class="metadata">
27+
<dt>
28+
<span class="label">{{ redirect.status_code }}</span>
29+
Redirect from
30+
</dt>
31+
<dd>
32+
{{ 'GET' != redirect.method ? redirect.method }}
33+
{% if redirect.controller.class is defined -%}
34+
{%- set link = controller.file|file_link(controller.line) -%}
35+
{% if link %}<a href="{{ link }}" title="{{ controller.file }}">{% endif -%}
36+
{{ redirect_route }}
37+
{%- if link %}</a>{% endif -%}
38+
{%- else -%}
39+
{{ redirect_route }}
40+
{%- endif %}
41+
(<a href="{{ path('_profiler', { token: redirect.token }) }}">{{ redirect.token }}</a>)
42+
</dd>
43+
</dl>
44+
{%- endif %}
45+
2246
<dl class="metadata">
2347
<dt>Method</dt>
2448
<dd>{{ profile.method|upper }}</dd>

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,11 @@ tr.status-warning td {
483483
#summary .status-error { background: {{ colors.error|raw }}; }
484484

485485
#summary .status-success h2,
486-
#summary .status-success h2 a,
486+
#summary .status-success a,
487487
#summary .status-warning h2,
488-
#summary .status-warning h2 a,
488+
#summary .status-warning a,
489489
#summary .status-error h2,
490-
#summary .status-error h2 a {
490+
#summary .status-error a {
491491
color: #FFF;
492492
}
493493

@@ -510,6 +510,10 @@ tr.status-warning td {
510510
margin: 0 1.5em 0 0;
511511
}
512512

513+
#summary dl.metadata .label {
514+
background: rgba(255, 255, 255, 0.2);
515+
}
516+
513517
{# Sidebar
514518
========================================================================= #}
515519
#sidebar {

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig
+18-5Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
.sf-toolbarreset {
3737
background-color: #222;
3838
bottom: 0;
39-
box-shadow: 0 -1px 0px rgba(0, 0, 0, 0.2);
39+
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
4040
color: #EEE;
4141
font: 11px Arial, sans-serif;
4242
left: 0;
@@ -138,7 +138,7 @@
138138

139139
.sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status {
140140
padding: 2px 5px;
141-
margin-bottom: 0px;
141+
margin-bottom: 0;
142142
}
143143
.sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status + .sf-toolbar-status {
144144
margin-left: 4px;
@@ -232,6 +232,16 @@
232232
.sf-toolbar-block-request .sf-toolbar-info-piece a:hover {
233233
text-decoration: underline;
234234
}
235+
.sf-toolbar-block-request .sf-toolbar-redirection-status {
236+
font-weight: normal;
237+
padding: 2px 4px;
238+
line-height: 18px;
239+
}
240+
.sf-toolbar-block-request .sf-toolbar-info-piece span.sf-toolbar-redirection-method {
241+
font-size: 12px;
242+
height: 17px;
243+
line-height: 17px;
244+
}
235245

236246
.sf-toolbar-status-green .sf-toolbar-label,
237247
.sf-toolbar-status-yellow .sf-toolbar-label,
@@ -380,7 +390,7 @@
380390

381391
.sf-toolbarreset {
382392
bottom: auto;
383-
box-shadow: 0 1px 0px rgba(0, 0, 0, 0.2);
393+
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
384394
top: 0;
385395
}
386396

@@ -450,9 +460,12 @@
450460
padding-left: 0;
451461
padding-right: 0;
452462
}
453-
.sf-toolbar-block-request .sf-toolbar-status + .sf-toolbar-label {
454-
margin-left: 4px;
463+
.sf-toolbar-block-request .sf-toolbar-status {
464+
margin-right: 5px;
455465
}
466+
.sf-toolbar-block-request .sf-toolbar-icon svg + .sf-toolbar-label {
467+
margin-left: 0;
468+
}
456469
.sf-toolbar-block-request .sf-toolbar-label + .sf-toolbar-value {
457470
margin-right: 10px;
458471
}

0 commit comments

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