Skip to content

Commit

Permalink
[WebProfilerBundle] inlined a service (closes #4717)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jul 3, 2012
1 parent 736aa21 commit f47b9a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Expand Up @@ -17,6 +17,7 @@
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.
Expand All @@ -25,6 +26,8 @@
*/
class ProfilerController extends ContainerAware
{
protected $templateManager;

/**
* Renders a profiler panel for the given token.
*
Expand All @@ -49,15 +52,13 @@ public function panelAction(Request $request, $token)
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(),
));
}
Expand Down Expand Up @@ -183,7 +184,7 @@ public function toolbarAction($token, $position = null)
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,
));
}
Expand Down Expand Up @@ -309,4 +310,18 @@ public function phpinfoAction()

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;
}
}
Expand Up @@ -6,7 +6,6 @@

<parameters>
<parameter key="web_profiler.debug_toolbar.class">Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener</parameter>
<parameter key="web_profiler.template_manager.class">Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager</parameter>
</parameters>

<services>
Expand All @@ -17,12 +16,5 @@
<argument>%web_profiler.debug_toolbar.mode%</argument>
<argument>%web_profiler.debug_toolbar.position%</argument>
</service>

<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" />
<argument>%data_collector.templates%</argument>
</service>
</services>
</container>

3 comments on commit f47b9a6

@Bladrak
Copy link

@Bladrak Bladrak commented on f47b9a6 Jul 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

The WebDebugToolbar is throwing an exception ever since this commit :

Catchable Fatal Error: Argument 2 passed to Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager::__construct() must be an instance of Symfony\Bundle\TwigBundle\TwigEngine, instance of Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine given, called in /Library/WebServer/Documents/sf21/vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php on line 322 and defined in /Library/WebServer/Documents/sf21/vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php line 40

@Tobion
Copy link
Member

@Tobion Tobion commented on f47b9a6 Jul 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #4720

@Bladrak
Copy link

@Bladrak Bladrak commented on f47b9a6 Jul 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.