Skip to content

Commit

Permalink
[WebProfilerBundle] tweaked previous merge
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jul 2, 2012
1 parent 155320a commit 7407773
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
Expand Up @@ -41,7 +41,6 @@ public function panelAction(Request $request, $token)
$panel = $this->container->get('request')->query->get('panel', 'request');
$page = $this->container->get('request')->query->get('page', 'home');


if (!$profile = $profiler->loadProfile($token)) {
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:info.html.twig', array('about' => 'no_token', 'token' => $token));
}
Expand All @@ -50,8 +49,7 @@ public function panelAction(Request $request, $token)
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
}

/** @var $templateManager \Symfony\Bundle\WebProfilerBundle\Profiler\Template */
$templateManager = $this->container->get('web_profiler.profiler_template');
$templateManager = $this->container->get('web_profiler.template_manager');

return $this->container->get('templating')->renderResponse($templateManager->getName($profile, $panel), array(
'token' => $token,
Expand Down Expand Up @@ -182,13 +180,10 @@ public function toolbarAction($token, $position = null)
// the profiler is not enabled
}

/** @var $templateManager \Symfony\Bundle\WebProfilerBundle\Profiler\Template */
$templateManager = $this->container->get('web_profiler.profiler_template');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:toolbar.html.twig', array(
'position' => $position,
'profile' => $profile,
'templates' => $templateManager->getTemplates($profile),
'templates' => $this->container->get('web_profiler.template_manager')->getTemplates($profile),
'profiler_url' => $url,
));
}
Expand Down
51 changes: 24 additions & 27 deletions src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php
Expand Up @@ -22,32 +22,20 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Artur Wielogórski <wodor@wodor.net>
*/
class TemplateManager {

/**
* @var \Symfony\Bundle\TwigBundle\TwigEngine
*/
class TemplateManager
{
protected $templating;

/**
* @var \Twig_Environment
*/
protected $twig;

/**
* @var array
*/
protected $templates;

/**
* @var \Symfony\Component\HttpKernel\Profiler\Profiler
*/
protected $profiler;

/**
* @param \Symfony\Bundle\TwigBundle\TwigEngine $templating
* Constructor.
*
* @param Profiler $profiler
* @param TwigEngine $templating
* @param \Twig_Environment $twig
* @param array $templates
* @param array $templates
*/
public function __construct(Profiler $profiler, TwigEngine $templating, \Twig_Environment $twig, array $templates)
{
Expand All @@ -58,10 +46,14 @@ public function __construct(Profiler $profiler, TwigEngine $templating, \Twig_En
}

/**
* @param \Symfony\Component\HttpKernel\Profiler\Profile $profile
* @param $panel
* Gets the template name for a given panel.
*
* @param Profile $profile
* @param string $panel
*
* @return mixed
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*
* @throws NotFoundHttpException
*/
public function getName(Profile $profile, $panel)
{
Expand All @@ -75,7 +67,10 @@ public function getName(Profile $profile, $panel)
}

/**
* @param \Symfony\Component\HttpKernel\Profiler\Profile $profile
* Gets the templates for a given profile.
*
* @param Profile $profile
*
* @return array
*/
public function getTemplates(Profile $profile)
Expand All @@ -89,10 +84,12 @@ public function getTemplates(Profile $profile)
}

/**
* Gets template names of templates that are
* present in the viewed profile
* @param \Symfony\Component\HttpKernel\Profiler\Profile $profile
* Gets template names of templates that are present in the viewed profile.
*
* @param Profile $profile
*
* @return array
*
* @throws \UnexpectedValueException
*/
protected function getNames(Profile $profile)
Expand Down Expand Up @@ -123,4 +120,4 @@ protected function getNames(Profile $profile)

return $templates;
}
}
}
Expand Up @@ -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\TemplateManager</parameter>
<parameter key="web_profiler.template_manager.class">Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager</parameter>
</parameters>

<services>
Expand All @@ -18,7 +18,7 @@
<argument>%web_profiler.debug_toolbar.position%</argument>
</service>

<service id="web_profiler.profiler_template" class="%web_profiler.profiler_template%">
<service id="web_profiler.template_manager" class="%web_profiler.template_manager.class%">
<argument type="service" id="profiler" />
<argument type="service" id="templating.engine.twig" />
<argument type="service" id="twig" />
Expand Down

0 comments on commit 7407773

Please sign in to comment.