Skip to content

Commit

Permalink
[TwigBundle] optimized the hinclude fragement renderer when only Twig…
Browse files Browse the repository at this point in the history
… is used
  • Loading branch information
fabpot committed Jan 12, 2015
1 parent 6148652 commit 2be8b6e
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
Expand Down Expand Up @@ -41,6 +42,17 @@ public function process(ContainerBuilder $container)

if ($container->has('fragment.handler')) {
$container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension');

// 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->getDefinition('fragment.renderer.hinclude')
->addTag('kernel.fragment_renderer', array('alias' => 'hinclude'))
->replaceArgument(0, new Reference('twig'))
;
}
}

if ($container->has('request_stack')) {
Expand Down

0 comments on commit 2be8b6e

Please sign in to comment.