File tree 2 files changed +16
-1
lines changed
src/Symfony/Bundle/TwigBundle
DependencyInjection/Compiler
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ public function process(ContainerBuilder $container)
66
66
67
67
if (!$ container ->has ('templating ' )) {
68
68
$ loader = $ container ->getDefinition ('twig.loader.native_filesystem ' );
69
+ $ loader ->replaceArgument (1 , $ this ->getComposerRootDir ($ container ->getParameter ('kernel.root_dir ' )));
69
70
$ loader ->addTag ('twig.loader ' );
70
71
$ loader ->setMethodCalls ($ container ->getDefinition ('twig.loader.filesystem ' )->getMethodCalls ());
71
72
@@ -91,4 +92,18 @@ public function process(ContainerBuilder $container)
91
92
$ container ->getDefinition ('twig.extension.expression ' )->addTag ('twig.extension ' );
92
93
}
93
94
}
95
+
96
+ private function getComposerRootDir ($ rootDir )
97
+ {
98
+ $ dir = $ rootDir ;
99
+ while (!file_exists ($ dir .'/composer.json ' )) {
100
+ if ($ dir === dirname ($ dir )) {
101
+ return $ rootDir ;
102
+ }
103
+
104
+ $ dir = dirname ($ dir );
105
+ }
106
+
107
+ return $ dir ;
108
+ }
94
109
}
Original file line number Diff line number Diff line change 46
46
47
47
<service id =" twig.loader.native_filesystem" class =" Twig_Loader_Filesystem" public =" false" >
48
48
<argument type =" collection" /> <!-- paths -->
49
- <argument >%kernel.root_dir% </argument >
49
+ <argument ></argument > <!-- project's root dir -- >
50
50
</service >
51
51
52
52
<service id =" twig.loader.filesystem" class =" Symfony\Bundle\TwigBundle\Loader\FilesystemLoader" public =" false" >
You can’t perform that action at this time.
0 commit comments