From f47b9a6625fdb8160d476f6c18f83249021fe57a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Jul 2012 10:02:51 +0200 Subject: [PATCH] [WebProfilerBundle] inlined a service (closes #4717) --- .../Controller/ProfilerController.php | 25 +++++++++++++++---- .../Resources/config/toolbar.xml | 8 ------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 9a4784b807..d917db3aac 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -17,6 +17,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; use Symfony\Component\HttpFoundation\Request; +use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; /** * ProfilerController. @@ -25,6 +26,8 @@ use Symfony\Component\HttpFoundation\Request; */ class ProfilerController extends ContainerAware { + protected $templateManager; + /** * Renders a profiler panel for the given token. * @@ -49,15 +52,13 @@ class ProfilerController extends ContainerAware throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token)); } - $templateManager = $this->container->get('web_profiler.template_manager'); - - return $this->container->get('templating')->renderResponse($templateManager->getName($profile, $panel), array( + return $this->container->get('templating')->renderResponse($this->getTemplateManager()->getName($profile, $panel), array( 'token' => $token, 'profile' => $profile, 'collector' => $profile->getCollector($panel), 'panel' => $panel, 'page' => $page, - 'templates' => $templateManager->getTemplates($profile), + 'templates' => $this->getTemplateManager()->getTemplates($profile), 'is_ajax' => $request->isXmlHttpRequest(), )); } @@ -183,7 +184,7 @@ class ProfilerController extends ContainerAware return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:toolbar.html.twig', array( 'position' => $position, 'profile' => $profile, - 'templates' => $this->container->get('web_profiler.template_manager')->getTemplates($profile), + 'templates' => $this->getTemplateManager()->getTemplates($profile), 'profiler_url' => $url, )); } @@ -309,4 +310,18 @@ class ProfilerController extends ContainerAware return new Response($phpinfo); } + + protected function getTemplateManager() + { + if (null === $this->templateManager) { + $this->templateManager = new TemplateManager( + $this->container->get('profiler'), + $this->container->get('templating'), + $this->container->get('twig'), + $this->container->getParameter('data_collector.templates') + ); + } + + return $this->templateManager; + } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml index 6741c596bc..5ce61a0889 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml @@ -6,7 +6,6 @@ Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener - Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager @@ -17,12 +16,5 @@ %web_profiler.debug_toolbar.mode% %web_profiler.debug_toolbar.position% - - - - - - %data_collector.templates% -