From b65d0a26eaf37994a180cfdc5fe44f784cdeac55 Mon Sep 17 00:00:00 2001 From: Alexander Schwenn Date: Tue, 7 Apr 2015 23:28:35 +0200 Subject: [PATCH] [WebProfilerBundle] Add link to show profile of latest request --- .../Controller/ProfilerController.php | 4 ++++ .../Resources/views/Profiler/info.html.twig | 15 +++++++++++---- .../Resources/views/Profiler/layout.html.twig | 1 + .../Resources/views/Profiler/profiler.css.twig | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 2748910a19..cada4ee6ca 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -91,6 +91,10 @@ class ProfilerController $panel = $request->query->get('panel', 'request'); $page = $request->query->get('page', 'home'); + if ('latest' === $token && $latest = current($this->profiler->find(null, null, 1, null, null, null))) { + $token = $latest['token']; + } + if (!$profile = $this->profiler->loadProfile($token)) { return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token)), 200, array('Content-Type' => 'text/html')); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig index aeffb2cf25..9be617a3ec 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig @@ -25,10 +25,17 @@ The token already exists in the database.

{% elseif about == 'no_token' %} -

Token not found

-

- Token "{{ token }}" was not found in the database. -

+ {% if token == 'latest' %} +

No profiles

+

+ No profiles found in the database. +

+ {% else %} +

Token not found

+

+ Token "{{ token }}" was not found in the database. +

+ {% endif %} {% endif %} {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig index 12728b964d..6df82890c1 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig @@ -14,6 +14,7 @@ {% if profile %}
View last 10 + View latest Profile for: {{ profile.method|upper }} {% if profile.method|upper in ['GET', 'HEAD'] %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig index 4d84a6931c..fd32565347 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig @@ -217,7 +217,7 @@ li { border-top-right-radius: 16px; line-height: 18px; } -a#resume-view-all { +a#resume-view-all, a#resume-view-latest { display: inline-block; padding: 0.2em 0.7em; margin-right: 0.5em;