File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
main/java/fr/adrienbrault/idea/symfony2plugin/templating/path
test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/path Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public class TwigPathServiceParser extends AbstractServiceParser {
16
16
17
17
@ Override
18
18
public String getXPathFilter () {
19
- return "/container/services/service[@id= 'twig.loader']//call[@method='addPath']" ;
19
+ return "/container/services/service[@id[starts-with(., 'twig.loader')] ]//call[@method='addPath']" ;
20
20
}
21
21
22
22
public synchronized void parser (InputStream file ) {
@@ -34,7 +34,12 @@ public synchronized void parser(InputStream file) {
34
34
if (arguments .getLength () == 1 ) {
35
35
twigPathIndex .addPath (new TwigPath (arguments .item (0 ).getTextContent ()));
36
36
} else if (arguments .getLength () == 2 ) {
37
- twigPathIndex .addPath (new TwigPath (arguments .item (0 ).getTextContent (), arguments .item (1 ).getTextContent ()));
37
+ String namespace = arguments .item (1 ).getTextContent ();
38
+
39
+ // we ignore overwrites; they are added also without "!", so just skip it
40
+ if (!namespace .startsWith ("!" )) {
41
+ twigPathIndex .addPath (new TwigPath (arguments .item (0 ).getTextContent (), namespace ));
42
+ }
38
43
}
39
44
}
40
45
}
Original file line number Diff line number Diff line change 12
12
* @author Daniel Espendiller <daniel@espendiller.net>
13
13
*/
14
14
public class TwigPathServiceParserTest extends Assert {
15
-
16
15
@ Test
17
16
public void testParse () throws Exception {
18
-
19
17
File testFile = new File ("src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/path/appDevDebugProjectContainer.xml" );
20
18
21
19
TwigPathServiceParser parser = new TwigPathServiceParser ();
@@ -27,6 +25,7 @@ public void testParse() throws Exception {
27
25
assertEquals ("vendor\\ symfony\\ symfony\\ src\\ Symfony\\ Bridge\\ Twig/Resources/views/Form" , parser .getTwigPathIndex ().getNamespacePaths (TwigUtil .MAIN ).get (0 ).getPath ());
28
26
assertEquals ("app/Resources/views" , parser .getTwigPathIndex ().getNamespacePaths (TwigUtil .MAIN ).get (1 ).getPath ());
29
27
28
+ assertEquals ("/app/vendor/symfony/twig-bundle/Resources/views2" , parser .getTwigPathIndex ().getNamespacePaths ("Twig2" ).get (0 ).getPath ());
29
+ assertEquals (0 , parser .getTwigPathIndex ().getNamespacePaths ("!Twig2" ).size ());
30
30
}
31
-
32
31
}
Original file line number Diff line number Diff line change 20
20
<argument >app/Resources/views</argument >
21
21
</call >
22
22
</service >
23
+
24
+ <service id =" twig.loader.native_filesystem" class =" Symfony\Bundle\TwigBundle\Loader\NativeFilesystemLoader" public =" false" >
25
+ <tag name =" twig.loader" />
26
+ <call method =" addPath" >
27
+ <argument >/app/vendor/symfony/twig-bundle/Resources/views2</argument >
28
+ <argument >Twig2</argument >
29
+ </call >
30
+ <call method =" addPath" >
31
+ <argument >/app/vendor/symfony/twig-bundle/Resources/views2</argument >
32
+ <argument >!Twig2</argument >
33
+ </call >
34
+ </service >
23
35
</services >
24
36
</container >
You can’t perform that action at this time.
0 commit comments