Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7037a44

Browse filesBrowse files
committed
inject project root path into twig filesystem loader
1 parent 8c22de4 commit 7037a44
Copy full SHA for 7037a44

File tree

3 files changed

+11
-6
lines changed
Filter options

3 files changed

+11
-6
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function process(ContainerBuilder $container)
6464
$container->getDefinition('twig.extension.debug')->addTag('twig.extension');
6565
}
6666

67+
$loader = $container->getDefinition('twig.loader.filesystem');
68+
$loader->replaceArgument(2, $this->getComposerRootDir($container->getParameter('kernel.root_dir')));
69+
6770
if (!$container->has('templating')) {
6871
$loader = $container->getDefinition('twig.loader.native_filesystem');
6972
$loader->replaceArgument(1, $this->getComposerRootDir($container->getParameter('kernel.root_dir')));

‎src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ class FilesystemLoader extends \Twig_Loader_Filesystem
2929
/**
3030
* Constructor.
3131
*
32-
* @param FileLocatorInterface $locator A FileLocatorInterface instance
33-
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
32+
* @param FileLocatorInterface $locator A FileLocatorInterface instance
33+
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
34+
* @param string $rootPath The project's root dir
3435
*/
35-
public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser)
36+
public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, $rootPath = '')
3637
{
37-
parent::__construct(array());
38+
parent::__construct(array(), $rootPath);
3839

3940
$this->locator = $locator;
4041
$this->parser = $parser;

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@
4646

4747
<service id="twig.loader.native_filesystem" class="Twig_Loader_Filesystem" public="false">
4848
<argument type="collection" /> <!-- paths -->
49-
<argument></argument> <!-- project's root dir -->
49+
<argument /> <!-- project's root dir -->
5050
</service>
5151

5252
<service id="twig.loader.filesystem" class="Symfony\Bundle\TwigBundle\Loader\FilesystemLoader" public="false">
5353
<argument type="service" id="templating.locator" />
5454
<argument type="service" id="templating.name_parser" />
55+
<argument /> <!-- project's root dir -->
5556
<tag name="twig.loader"/>
5657
</service>
5758

@@ -87,7 +88,7 @@
8788

8889
<service id="twig.extension.code" class="Symfony\Bridge\Twig\Extension\CodeExtension" public="false">
8990
<tag name="twig.extension" />
90-
<argument type="service" id="debug.file_link_formatter"></argument>
91+
<argument type="service" id="debug.file_link_formatter" />
9192
<argument>%kernel.root_dir%</argument>
9293
<argument>%kernel.charset%</argument>
9394
</service>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.