8000 [WebProfilerBundle] removed dependency on the templating component · s7ntech/symfony@dfc53b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit dfc53b0

Browse files
committed
[WebProfilerBundle] removed dependency on the templating component
1 parent c682f67 commit dfc53b0

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ protected function getTemplateManager()
321321
if (null === $this->templateManager) {
322322
$this->templateManager = new TemplateManager(
323323
$this->container->get('profiler'),
324-
$this->container->get('templating'),
325324
$this->container->get('twig'),
326325
$this->container->getParameter('data_collector.templates')
327326
);

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1818
use Symfony\Component\HttpKernel\KernelEvents;
1919
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
20-
use Symfony\Bundle\TwigBundle\TwigEngine;
2120

2221
/**
2322
* WebDebugToolbarListener injects the Web Debug Toolbar.
@@ -31,17 +30,17 @@
3130
*/
3231
class WebDebugToolbarListener implements EventSubscriberInterface
3332
{
34-
const DISABLED = 1;
35-
const ENABLED = 2;
33+
const DISABLED = 1;
34+
const ENABLED = 2;
3635

37-
protected $templating;
36+
protected $twig;
3837
protected $interceptRedirects;
3938
protected $mode;
4039
protected $position;
4140

42-
public function __construct(TwigEngine $templating, $interceptRedirects = false, $mode = self::ENABLED, $position = 'bottom')
41+
public function __construct(\Twig_Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, $position = 'bottom')
4342
{
44-
$this->templating = $templating;
43+
$this->twig = $twig;
4544
$this->interceptRedirects = (Boolean) $interceptRedirects;
4645
$this->mode = (integer) $mode;
4746
$this->position = $position;
@@ -73,7 +72,7 @@ public function onKernelResponse(FilterResponseEvent $event)
7372
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
7473
}
7574

76-
$response->setContent($this->templating->render('WebProfilerBundle:Profiler:toolbar_redirect.html.twig', array('location' => $response->headers->get('Location'))));
75+
$response->setContent($this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', array('location' => $response->headers->get('Location'))));
7776
$response->setStatusCode(200);
7877
$response->headers->remove('Location');
7978
}
@@ -109,8 +108,8 @@ protected function injectToolbar(Response $response)
109108
$pos = $posrFunction($content, '</body>');
110109

111110
if (false !== $pos) {
112-
$toolbar = "\n".str_replace("\n", '', $this->templating->render(
113-
'WebProfilerBundle:Profiler:toolbar_js.html.twig',
111+
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
112+
'@WebProfiler/Profiler/toolbar_js.html.twig',
114113
array(
115114
'position' => $this->position,
116115
'token' => $response->headers->get('X-Debug-Token'),

src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1515
use Symfony\Component\HttpKernel\Profiler\Profiler;
1616
use Symfony\Component\HttpKernel\Profiler\Profile;
17-
use Symfony\Component\Templating\EngineInterface;
1817

1918
/**
2019
* Profiler Templates Manager
@@ -24,7 +23,6 @@
2423
*/
2524
class TemplateManager
2625
{
27-
protected $templating;
2826
protected $twig;
2927
protected $templates;
3028
protected $profiler;
@@ -33,14 +31,12 @@ class TemplateManager
3331
* Constructor.
3432
*
3533
* @param Profiler $profiler
36-
* @param TwigEngine $templating
3734
* @param \Twig_Environment $twig
3835
* @param array $templates
3936
*/
40-
public function __construct(Profiler $profiler, EngineInterface $templating, \Twig_Environment $twig, array $templates)
37+
public function __construct(Profiler $profiler, \Twig_Environment $twig, array $templates)
4138
{
4239
$this->profiler = $profiler;
43-
$this->templating = $templating;
4440
$this->twig = $twig;
4541
$this->templates = $templates;
4642
}
@@ -111,10 +107,12 @@ protected function getNames(Profile $profile)
111107
$template = substr($template, 0, -10);
112108
}
113109

114-
if (!$this->templating->exists($template.'.html.twig')) {
110+
// FIXME when Twig is able to check for template existence
111+
/*
112+
if (!$this->twig->exists($template.'.html.twig')) {
115113
throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
116114
}
117-
115+
*/
118116
$templates[$name] = $template.'.html.twig';
119117
}
120118

src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<services>
1212
<service id="web_profiler.debug_toolbar" class="%web_profiler.debug_toolbar.class%">
1313
<tag name="kernel.event_subscriber" />
14-
<argument type="service" id="templating.engine.twig" />
14+
<argument type="service" id="twig" />
1515
<argument>%web_profiler.debug_toolbar.intercept_redirects%</argument>
1616
<argument>%web_profiler.debug_toolbar.mode%</argument>
1717
<argument>%web_profiler.debug_toolbar.position%</argument>

0 commit comments

Comments
 (0)
0