Skip to content

Commit 815839f

Browse files
authored
Merge pull request Haehnchen#1316 from Haehnchen/feature/twig-controller-escape
support double backslashes for Twig controller references
2 parents a1b57b1 + f865aca commit 815839f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ public static PsiElement[] getMethodsOnControllerShortcut(@NotNull Project proje
155155
return new PsiElement[0];
156156
}
157157

158+
// escaping
159+
// "Foobar\\Test"
160+
controllerName = controllerName.replace("\\\\", "\\");
161+
158162
if(controllerName.contains("::")) {
159163

160164
// FooBundle\Controller\BarController::fooBarAction

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/TwigTemplateGoToDeclarationHandlerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ public void testThatConstantProvidesNavigation() {
171171
assertNavigationMatch(TwigFileType.INSTANCE, "{{ constant('CONST<caret>_FOO') }}", PlatformPatterns.psiElement());
172172
}
173173

174+
public void testTestControllerActionsProvidesReferences() {
175+
assertNavigationMatch(TwigFileType.INSTANCE, "{{ controller('\\FooBundle\\Cont<caret>roller\\FooController::barAction') }}", PlatformPatterns.psiElement(Method.class).withName("barAction"));
176+
assertNavigationMatch(TwigFileType.INSTANCE, "{{ controller('\\\\FooBundle\\\\Cont<caret>roller\\\\FooController::barAction') }}", PlatformPatterns.psiElement(Method.class).withName("barAction"));
177+
assertNavigationMatch(TwigFileType.INSTANCE, "{{ controller('FooBundle\\Cont<caret>roller\\FooController::barAction') }}", PlatformPatterns.psiElement(Method.class).withName("barAction"));
178+
assertNavigationMatch(TwigFileType.INSTANCE, "{{ controller('FooBundle\\\\Cont<caret>roller\\\\FooController::barAction') }}", PlatformPatterns.psiElement(Method.class).withName("barAction"));
179+
}
180+
174181
public void testFunctionNavigation() {
175182
assertNavigationMatch(
176183
TwigFileType.INSTANCE,

0 commit comments

Comments
 (0)