diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 90bb1a431d..d6cfc54648 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -52,7 +52,6 @@ class ProfilerController extends ContainerAware /** @var $templateManager \Symfony\Bundle\WebProfilerBundle\Profiler\Template */ $templateManager = $this->container->get('web_profiler.profiler_template'); - $templateManager->setProfiler($profiler); return $this->container->get('templating')->renderResponse($templateManager->getName($profile, $panel), array( 'token' => $token, @@ -185,7 +184,6 @@ class ProfilerController extends ContainerAware /** @var $templateManager \Symfony\Bundle\WebProfilerBundle\Profiler\Template */ $templateManager = $this->container->get('web_profiler.profiler_template'); - $templateManager->setProfiler($profiler); return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:toolbar.html.twig', array( 'position' => $position, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Profiler/Template.php b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php similarity index 91% rename from src/Symfony/Bundle/WebProfilerBundle/Profiler/Template.php rename to src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php index d2021bd5ad..40643fbf03 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Profiler/Template.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php @@ -17,12 +17,12 @@ use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Bundle\TwigBundle\TwigEngine; /** - * ProfilerController. + * Profiler Templates Manager * * @author Fabien Potencier * @author Artur Wielogórski */ -class Template { +class TemplateManager { /** * @var \Symfony\Bundle\TwigBundle\TwigEngine @@ -49,8 +49,9 @@ class Template { * @param \Twig_Environment $twig * @param array $templates */ - public function __construct(TwigEngine $templating, \Twig_Environment $twig, array $templates) + public function __construct(Profiler $profiler, TwigEngine $templating, \Twig_Environment $twig, array $templates) { + $this->profiler = $profiler; $this->templating = $templating; $this->twig = $twig; $this->templates = $templates; @@ -87,14 +88,6 @@ class Template { return $templates; } - /** - * @param \Symfony\Component\HttpKernel\Profiler\Profiler $profiler - */ - public function setProfiler(Profiler $profiler) - { - $this->profiler = $profiler; - } - /** * Gets template names of templates that are * present in the viewed profile diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml index eca157f5a1..69771f84a2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml @@ -6,7 +6,7 @@ Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener - Symfony\Bundle\WebProfilerBundle\Profiler\Template + Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager @@ -19,6 +19,7 @@ + %data_collector.templates% diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index db92a4b545..dbd0ed020c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -65,6 +65,8 @@ class WebProfilerExtensionTest extends TestCase $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); $this->container->setParameter('kernel.root_dir', __DIR__); + $this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')) + ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface'))); $this->container->setParameter('data_collector.templates', array()); $this->container->set('kernel', $this->kernel); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php similarity index 92% rename from src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateTest.php rename to src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 514acc658b..59bfa4d892 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -12,14 +12,14 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Profiler; use Symfony\Bundle\WebProfilerBundle\Tests\TestCase; -use Symfony\Bundle\WebProfilerBundle\Profiler\Template; +use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; /** - * Test for Template class. + * Test for TemplateManager class. * * @author Artur Wielogórski */ -class TemplateTest extends TestCase +class TemplateManagerTest extends TestCase { /** * @var \Symfony\Bundle\TwigBundle\TwigEngine @@ -42,7 +42,7 @@ class TemplateTest extends TestCase protected $profile; /** - * @var \Symfony\Bundle\WebProfilerBundle\Profiler\Template + * @var \Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager */ protected $templateManager; @@ -50,6 +50,7 @@ class TemplateTest extends TestCase { parent::setUp(); + $profiler = $this->mockProfiler(); $twigEngine = $this->mockTwigEngine(); $twigEnvironment = $this->mockTwigEnvironment(); $templates = array( @@ -58,8 +59,7 @@ class TemplateTest extends TestCase 'data_collector.baz'=>array('baz','FooBundle:Collector:baz') ); - $this->templateManager = new Template($twigEngine, $twigEnvironment, $templates); - $this->templateManager->setProfiler($this->mockProfiler()); + $this->templateManager = new TemplateManager($profiler, $twigEngine, $twigEnvironment, $templates); } /** @@ -148,7 +148,6 @@ class TemplateTest extends TestCase ->will($this->returnValue('loadedTemplate')); return $this->twigEnvironment; - } protected function mockTwigEngine() @@ -162,7 +161,6 @@ class TemplateTest extends TestCase ->will($this->returnValue(true)); return $this->twigEngine; - } protected function mockProfiler() {