8000 Fix usage of TwigBundle without FrameworkBundle · symfony/symfony@9a85049 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a85049

Browse files
committed
Fix usage of TwigBundle without FrameworkBundle
1 parent d571edc commit 9a85049

File tree

6 files changed

+64
-56
lines changed

6 files changed

+64
-56
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public function process(ContainerBuilder $container)
6565
if ($container->has('fragment.handler')) {
6666
$container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension');
6767

68+
$container->getDefinition('twig.runtime.httpkernel')
69+
->replaceArgument(0, new Reference('fragment.handler'))
70+
->addTag('twig.runtime')
71+
;
72+
6873
// inject Twig in the hinclude service if Twig is the only registered templating engine
6974
if ((!$container->hasParameter('templating.engines') || array('twig') == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) {
7075
$container->getDefinition('fragment.renderer.hinclude')
@@ -74,6 +79,12 @@ public function process(ContainerBuilder $container)
7479
}
7580
}
7681

82+
if ($container->has('http_kernel')) {
83+
$container->getDefinition('twig.controller.preview_error')
84+
->replaceArgument(0, new Reference('http_kernel'))
85+
;
86+
}
87+
7788
if ($container->has('request_stack')) {
7889
$container->getDefinition('twig.extension.httpfoundation')->addTag('twig.extension');
7990
}

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@
104104
<service id="twig.extension.httpkernel" class="Symfony\Bridge\Twig\Extension\HttpKernelExtension" />
105105

106106
<service id="twig.runtime.httpkernel" class="Symfony\Bridge\Twig\Extension\HttpKernelRuntime">
107-
<argument type="service" id="fragment.handler" />
108-
<tag name="twig.runtime" />
107+
<argument />
109108
</service>
110109

111110
<service id="twig.extension.httpfoundation" class="Symfony\Bridge\Twig\Extension\HttpFoundationExtension">
@@ -142,7 +141,7 @@
142141
</service>
143142

144143
<service id="twig.controller.preview_error" class="Symfony\Bundle\TwigBundle\Controller\PreviewErrorController" public="true">
145-
<argument type="service" id="http_kernel" />
144+
<argument />
146145
<argument>%twig.exception_listener.controller%</argument>
147146
</service>
148147

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\TwigBundle\Tests\Functional;
13+
14+
use Symfony\Bundle\TwigBundle\Tests\TestCase;
15+
use Symfony\Bundle\TwigBundle\TwigBundle;
16+
use Symfony\Component\Config\Loader\LoaderInterface;
17+
use Symfony\Component\HttpKernel\Kernel;
18+
19+
class EmptyAppTest extends TestCase
20+
{
21+
public function testBootEmptyApp()
22+
{
23+
$kernel = new EmptyAppKernel('test', true);
24+
$kernel->boot();
25+
26+
$this->assertTrue($kernel->getContainer()->hasParameter('twig.default_path'));
27+
$this->assertNotEmpty($kernel->getContainer()->getParameter('twig.default_path'));
28+
}
29+
}
30+
31+
class EmptyAppKernel extends Kernel
32+
{
33+
public function registerBundles()
34+
{
35+
return array(new TwigBundle());
36+
}
37+
38+
public function registerContainerConfiguration(LoaderInterface $loader)
39+
{
40+
}
41+
42+
public function getCacheDir()
43+
{
44+
return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/cache/'.$this->environment;
45+
}
46+
47+
public function getLogDir()
48+
{
49+
return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/logs';
50+
}
51+
}

src/Symfony/Bundle/TwigBundle/Tests/FunctionalEmpty/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/Symfony/Bundle/TwigBundle/Tests/FunctionalEmpty/EmptyAppKernel.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Symfony/Bundle/TwigBundle/Tests/FunctionalEmpty/EmptyAppTest.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0