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

Skip to content

Commit 0e5eb6b

Browse files
committed
feature #14264 [WebProfilerBundle] Add link to show profile of latest request (xelaris)
This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #14264). Discussion ---------- [WebProfilerBundle] Add link to show profile of latest request | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This PR adds a "View latest" link next to "View last 10" to enable quick access to the profile of the latest request. This is useful especially when using the profiler along with a REST client. After sending a new request it is now possible to view the latest profile with just one click. Commits ------- b65d0a2 [WebProfilerBundle] Add link to show profile of latest request
2 parents b7d003e + b65d0a2 commit 0e5eb6b

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public function panelAction(Request $request, $token)
9191
$panel = $request->query->get('panel', 'request');
9292
$page = $request->query->get('page', 'home');
9393

94+
if ('latest' === $token && $latest = current($this->profiler->find(null, null, 1, null, null, null))) {
95+
$token = $latest['token'];
96+
}
97+
9498
if (!$profile = $this->profiler->loadProfile($token)) {
9599
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token)), 200, array('Content-Type' => 'text/html'));
96100
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@
2525
<em>The token already exists in the database.</em>
2626
</p>
2727
{% elseif about == 'no_token' %}
28-
<h2>Token not found</h2>
29-
<p>
30-
<em>Token "{{ token }}" was not found in the database.</em>
31-
</p>
28+
{% if token == 'latest' %}
29+
<h2>No profiles</h2>
30+
<p>
31+
<em>No profiles found in the database.</em>
32+
</p>
33+
{% else %}
34+
<h2>Token not found</h2>
35+
<p>
36+
<em>Token "{{ token }}" was not found in the database.</em>
37+
</p>
38+
{% endif %}
3239
{% endif %}
3340
{% endblock %}
3441
</div>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
{% if profile %}
1515
<div id="resume">
1616
<a id="resume-view-all" href="{{ path('_profiler_search', {limit: 10}) }}">View last 10</a>
17+
<a id="resume-view-latest" href="{{ path('_profiler', {token: 'latest', 'panel': panel}) }}">View latest</a>
1718
<strong>Profile for:</strong>
1819
{{ profile.method|upper }}
1920
{% if profile.method|upper in ['GET', 'HEAD'] %}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ li {
217217
border-top-right-radius: 16px;
218218
line-height: 18px;
219219
}
220-
a#resume-view-all {
220+
a#resume-view-all, a#resume-view-latest {
221221
display: inline-block;
222222
padding: 0.2em 0.7em;
223223
margin-right: 0.5em;

0 commit comments

Comments
 (0)