diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/SymfonyPhpReferenceContributor.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/SymfonyPhpReferenceContributor.java index 6caa9fff2..f226ca3be 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/SymfonyPhpReferenceContributor.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/SymfonyPhpReferenceContributor.java @@ -98,6 +98,9 @@ public class SymfonyPhpReferenceContributor extends PsiReferenceContributor { new MethodMatcher.CallToSignature("\\Twig\\Environment", "display"), new MethodMatcher.CallToSignature("\\Twig\\Environment", "isTemplateFresh"), new MethodMatcher.CallToSignature("\\Twig\\Environment", "resolveTemplate"), // @TODO: also "is_array($names)" + + new MethodMatcher.CallToSignature("\\Symfony\\Bridge\\Twig\\Mime\\TemplatedEmail", "htmlTemplate"), + new MethodMatcher.CallToSignature("\\Symfony\\Bridge\\Twig\\Mime\\TemplatedEmail", "textTemplate"), }; @Override diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/util/PhpMethodVariableResolveUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/util/PhpMethodVariableResolveUtil.java index 5241b286d..18892ee1e 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/util/PhpMethodVariableResolveUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/util/PhpMethodVariableResolveUtil.java @@ -30,6 +30,7 @@ import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; import static fr.adrienbrault.idea.symfony2plugin.util.StringUtils.underscore; @@ -310,7 +311,7 @@ public static void processMethodReference(@NotNull MethodReference methodReferen return; } - if(!methods.get().contains(methodName) && !methodName.toLowerCase().contains("render")) { + if (!methods.get().contains(methodName) && Stream.of("render", "htmltemplate", "texttemplate").noneMatch(s -> methodName.toLowerCase().contains(s))) { return; } diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/PhpTwigTemplateUsageStubIndexTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/PhpTwigTemplateUsageStubIndexTest.java index d95f8205b..73fbbfb13 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/PhpTwigTemplateUsageStubIndexTest.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/PhpTwigTemplateUsageStubIndexTest.java @@ -36,9 +36,11 @@ public void testThatTwigRenderMethodsAreInIndex() { " $foo->render($this->foo);\n" + " $foo->render(\\DateTime::foo);\n" + " $foo->renderView($defaultParameter);\n" + + " $foo1->htmlTemplate('emails/signup.html.twig');\n" + + " $foo1->textTemplate('emails/signup.txt.twig');\n" + " }\n" + "}" + - "" + + "\n" + "function foobarFunc()" + "{\n" + " $foo->render('foo-render.html.twig')\n" + @@ -50,7 +52,7 @@ public void testThatTwigRenderMethodsAreInIndex() { "foo-render.html.twig", "foo-renderView.html.twig", "foo-renderResponse.html.twig", "@Foo/overwrite.html.twig", "const.html.twig", "var.html.twig", "private.html.twig", "foobar-render.twig", "foo-render-ternary.html.twig", "const-ternary.html.twig", "foo-render-coalesce.html.twig", "const-coalesce.html.twig", - "foo-var-assignment-expression.html.twig", "default-function-parameter.html.twig" + "foo-var-assignment-expression.html.twig", "default-function-parameter.html.twig", "emails/signup.html.twig", "emails/signup.txt.twig" ); assertIndexContainsKeyWithValue(PhpTwigTemplateUsageStubIndex.KEY, "foo-render.html.twig", value ->