inject project root path into twig filesystem loader
This commit is contained in:
parent
8c22de44cd
commit
1094773999
@ -64,9 +64,13 @@ class ExtensionPass implements CompilerPassInterface
|
||||
$container->getDefinition('twig.extension.debug')->addTag('twig.extension');
|
||||
}
|
||||
|
||||
$composerRootDir = $this->getComposerRootDir($container->getParameter('kernel.root_dir'));
|
||||
$loader = $container->getDefinition('twig.loader.filesystem');
|
||||
$loader->replaceArgument(2, $composerRootDir);
|
||||
|
||||
if (!$container->has('templating')) {
|
||||
$loader = $container->getDefinition('twig.loader.native_filesystem');
|
||||
$loader->replaceArgument(1, $this->getComposerRootDir($container->getParameter('kernel.root_dir')));
|
||||
$loader->replaceArgument(1, $composerRootDir);
|
||||
$loader->addTag('twig.loader');
|
||||
$loader->setMethodCalls($container->getDefinition('twig.loader.filesystem')->getMethodCalls());
|
||||
|
||||
|
@ -29,12 +29,13 @@ class FilesystemLoader extends \Twig_Loader_Filesystem
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param FileLocatorInterface $locator A FileLocatorInterface instance
|
||||
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
|
||||
* @param FileLocatorInterface $locator A FileLocatorInterface instance
|
||||
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
|
||||
* @param string|null $rootPath The root path common to all relative paths (null for getcwd())
|
||||
*/
|
||||
public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser)
|
||||
public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, $rootPath = null)
|
||||
{
|
||||
parent::__construct(array());
|
||||
parent::__construct(array(), $rootPath);
|
||||
|
||||
$this->locator = $locator;
|
||||
$this->parser = $parser;
|
||||
|
@ -46,12 +46,13 @@
|
||||
|
||||
<service id="twig.loader.native_filesystem" class="Twig_Loader_Filesystem" public="false">
|
||||
<argument type="collection" /> <!-- paths -->
|
||||
<argument></argument> <!-- project's root dir -->
|
||||
<argument /> <!-- project's root dir -->
|
||||
</service>
|
||||
|
||||
<service id="twig.loader.filesystem" class="Symfony\Bundle\TwigBundle\Loader\FilesystemLoader" public="false">
|
||||
<argument type="service" id="templating.locator" />
|
||||
<argument type="service" id="templating.name_parser" />
|
||||
<argument /> <!-- project's root dir -->
|
||||
<tag name="twig.loader"/>
|
||||
</service>
|
||||
|
||||
@ -87,7 +88,7 @@
|
||||
|
||||
<service id="twig.extension.code" class="Symfony\Bridge\Twig\Extension\CodeExtension" public="false">
|
||||
<tag name="twig.extension" />
|
||||
<argument type="service" id="debug.file_link_formatter"></argument>
|
||||
<argument type="service" id="debug.file_link_formatter" />
|
||||
<argument>%kernel.root_dir%</argument>
|
||||
<argument>%kernel.charset%</argument>
|
||||
</service>
|
||||
|
Reference in New Issue
Block a user