diff --git a/DependencyInjection/Compiler/ThemeCompilerPass.php b/DependencyInjection/Compiler/ThemeCompilerPass.php index 30949cc..47e482f 100644 --- a/DependencyInjection/Compiler/ThemeCompilerPass.php +++ b/DependencyInjection/Compiler/ThemeCompilerPass.php @@ -23,11 +23,31 @@ public function process(ContainerBuilder $container) $container->setAlias('templating.cache_warmer.template_paths', 'liip_theme.templating.cache_warmer.template_paths'); - $container->setAlias('twig.loader', 'liip_theme.twig.loader.filesystem'); + if (true === $container->hasDefinition('twig')) { + $twigLoader = $container->findDefinition('twig.loader'); + if ('Twig_Loader_Chain' == $class = $container->getParameterBag()->resolveValue($twigLoader->getClass())) { + $methodCalls = $twigLoader->getMethodCalls(); + foreach($methodCalls as $index => $methodCall) { + if ($methodCall[0] == 'addLoader' && (string) $methodCall[1][0] == 'twig.loader.filesystem') { + $methodCalls[$index] = array($methodCall[0], array(new Reference('liip_theme.twig.loader.filesystem'))); + } + } + $twigLoader->setMethodCalls($methodCalls); + } else { + $id = 'twig.loader'; + while($container->hasAlias($id)) { + $id = $container->getAlias($id); + } + if($id == 'twig.loader.filesystem') { + $container->setAlias('twig.loader', 'liip_theme.twig.loader.filesystem'); + } + } + } if (!$container->getParameter('liip_theme.cache_warming')) { $container->getDefinition('liip_theme.templating.cache_warmer.template_paths') ->replaceArgument(2, null); } } + } diff --git a/Loader/FilesystemLoader.php b/Loader/FilesystemLoader.php index c549123..0fd2de5 100644 --- a/Loader/FilesystemLoader.php +++ b/Loader/FilesystemLoader.php @@ -36,7 +36,4 @@ protected function findTemplate($template) return $file; } - - - } \ No newline at end of file diff --git a/Resources/config/templating.xml b/Resources/config/templating.xml index b2ad142..e405a52 100644 --- a/Resources/config/templating.xml +++ b/Resources/config/templating.xml @@ -30,7 +30,6 @@ -