From 18472853226756ed1abe3feb1c2de7d6924a4883 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 20 Jul 2015 15:23:16 +0200 Subject: [PATCH] Pass the toolbar version number from the controller, to ease transition and keep BC --- .../Controller/ProfilerController.php | 19 +++++++++++++------ .../views/Profiler/toolbar.html.twig | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index cada4ee6ca..558966f415 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -11,13 +11,14 @@ namespace Symfony\Bundle\WebProfilerBundle\Controller; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; -use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** @@ -27,6 +28,9 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; */ class ProfilerController { + const TOOLBAR_VERSION_1 = 1; + const TOOLBAR_VERSION_2 = 2; + private $templateManager; private $generator; private $profiler; @@ -201,12 +205,15 @@ class ProfilerController // the profiler is not enabled } + $toolbarVersion = Kernel::VERSION_ID < 20800 ? self::TOOLBAR_VERSION_1 : self::TOOLBAR_VERSION_2; + return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array( 'position' => $position, 'profile' => $profile, 'templates' => $this->getTemplateManager()->getTemplates($profile), 'profiler_url' => $url, 'token' => $token, + 'toolbar_version' => $toolbarVersion, )), 200, array('Content-Type' => 'text/html')); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig index 58c125268e..cc47a2ef7d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig @@ -30,7 +30,8 @@ 'collector': profile.getcollector(name), 'profiler_url': profiler_url, 'token': profile.token, - 'name': name + 'name': name, + 'toolbar_version': toolbar_version }) }} {% endfor %}