renamed template to TemplateManager , moved profiler to the deps of manager

This commit is contained in:
Wodor Wodorski 2012-02-18 11:02:30 +01:00
parent 5fd6ed6cff
commit bc73487382
5 changed files with 14 additions and 22 deletions

View File

@ -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,

View File

@ -17,12 +17,12 @@ use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Bundle\TwigBundle\TwigEngine;
/**
* ProfilerController.
* Profiler Templates Manager
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Artur Wielogórski <wodor@wodor.net>
*/
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

View File

@ -6,7 +6,7 @@
<parameters>
<parameter key="web_profiler.debug_toolbar.class">Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener</parameter>
<parameter key="web_profiler.profiler_template">Symfony\Bundle\WebProfilerBundle\Profiler\Template</parameter>
<parameter key="web_profiler.profiler_template">Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager</parameter>
</parameters>
<services>
@ -19,6 +19,7 @@
</service>
<service id="web_profiler.profiler_template" class="%web_profiler.profiler_template%">
<argument type="service" id="profiler" />
<argument type="service" id="templating.engine.twig" />
<argument type="service" id="twig" />
<argument>%data_collector.templates%</argument>

View File

@ -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);
}

View File

@ -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 <wodor@wodor.net>
*/
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() {