diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 0292f6f6a4..5089fc0651 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -64,6 +64,7 @@ class ExtensionPass implements CompilerPassInterface if ($container->has('fragment.handler')) { $container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension'); + $container->getDefinition('twig.runtime.httpkernel')->addTag('twig.runtime'); // inject Twig in the hinclude service if Twig is the only registered templating engine if ((!$container->hasParameter('templating.engines') || array('twig') == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) { @@ -74,6 +75,10 @@ class ExtensionPass implements CompilerPassInterface } } + if (!$container->has('http_kernel')) { + $container->removeDefinition('twig.controller.preview_error'); + } + if ($container->has('request_stack')) { $container->getDefinition('twig.extension.httpfoundation')->addTag('twig.extension'); } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 865672944f..ed4f46c0b6 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -36,11 +36,14 @@ class TwigExtension extends Extension $loader->load('twig.xml'); $container->getDefinition('twig.profile')->setPrivate(true); - $container->getDefinition('twig.runtime.httpkernel')->setPrivate(true); $container->getDefinition('twig.translation.extractor')->setPrivate(true); $container->getDefinition('workflow.twig_extension')->setPrivate(true); $container->getDefinition('twig.exception_listener')->setPrivate(true); + if ($container->has('fragment.handler')) { + $container->getDefinition('twig.runtime.httpkernel')->setPrivate(true); + } + if (class_exists('Symfony\Component\Form\Form')) { $loader->load('form.xml'); $container->getDefinition('twig.form.renderer')->setPrivate(true); diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 3fa98b8bef..5b2315e6d1 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -105,7 +105,6 @@ - diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php new file mode 100644 index 0000000000..b25d6ad650 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Functional; + +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Bundle\TwigBundle\TwigBundle; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Kernel; + +class EmptyAppTest extends TestCase +{ + public function testBootEmptyApp() + { + $kernel = new EmptyAppKernel('test', true); + $kernel->boot(); + + $this->assertTrue($kernel->getContainer()->hasParameter('twig.default_path')); + $this->assertNotEmpty($kernel->getContainer()->getParameter('twig.default_path')); + } +} + +class EmptyAppKernel extends Kernel +{ + public function registerBundles() + { + return array(new TwigBundle()); + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/cache/'.$this->environment; + } + + public function getLogDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/logs'; + } +}