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 {
1616
1717 @ Override
1818 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']" ;
2020 }
2121
2222 public synchronized void parser (InputStream file ) {
@@ -34,7 +34,12 @@ public synchronized void parser(InputStream file) {
3434 if (arguments .getLength () == 1 ) {
3535 twigPathIndex .addPath (new TwigPath (arguments .item (0 ).getTextContent ()));
3636 } 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+ }
3843 }
3944 }
4045 }
Original file line number Diff line number Diff line change 1212 * @author Daniel Espendiller <daniel@espendiller.net>
1313 */
1414public class TwigPathServiceParserTest extends Assert {
15-
1615 @ Test
1716 public void testParse () throws Exception {
18-
1917 File testFile = new File ("src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/path/appDevDebugProjectContainer.xml" );
2018
2119 TwigPathServiceParser parser = new TwigPathServiceParser ();
@@ -27,6 +25,7 @@ public void testParse() throws Exception {
2725 assertEquals ("vendor\\ symfony\\ symfony\\ src\\ Symfony\\ Bridge\\ Twig/Resources/views/Form" , parser .getTwigPathIndex ().getNamespacePaths (TwigUtil .MAIN ).get (0 ).getPath ());
2826 assertEquals ("app/Resources/views" , parser .getTwigPathIndex ().getNamespacePaths (TwigUtil .MAIN ).get (1 ).getPath ());
2927
28+ assertEquals ("/app/vendor/symfony/twig-bundle/Resources/views2" , parser .getTwigPathIndex ().getNamespacePaths ("Twig2" ).get (0 ).getPath ());
29+ assertEquals (0 , parser .getTwigPathIndex ().getNamespacePaths ("!Twig2" ).size ());
3030 }
31-
3231}
Original file line number Diff line number Diff line change 2020 <argument >app/Resources/views</argument >
2121 </call >
2222 </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 >
2335 </services >
2436</container >
You can’t perform that action at this time.
0 commit comments