Skip to content

Commit 47c4b73

Browse files
committed
use slash for controller subfolder which are PHP namespaces instead of filesystem style to fix autocompletion for controller names in routing files is broken for namespaced classes #961
1 parent cfc948a commit 47c4b73

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

src/fr/adrienbrault/idea/symfony2plugin/util/controller/ControllerIndex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private List<ControllerAction> getActionMethods(SymfonyBundle symfonyBundle) {
114114
for(Method method : phpClass.getMethods()) {
115115
String methodName = method.getName();
116116
if(methodName.endsWith("Action") && method.getAccess().isPublic()) {
117-
String shortcutName = symfonyBundle.getName() + ":" + ns.replace("\\", "/") + ':' + methodName.substring(0, methodName.length() - 6);
117+
String shortcutName = symfonyBundle.getName() + ":" + ns.replace("/", "\\") + ':' + methodName.substring(0, methodName.length() - 6);
118118
actions.add(new ControllerAction(shortcutName, method));
119119
}
120120

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.util.controller;
2+
3+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
4+
import fr.adrienbrault.idea.symfony2plugin.util.controller.ControllerAction;
5+
import fr.adrienbrault.idea.symfony2plugin.util.controller.ControllerIndex;
6+
7+
import java.io.File;
8+
import java.util.Collection;
9+
10+
/**
11+
* @author Daniel Espendiller <daniel@espendiller.net>
12+
*/
13+
public class ControllerIndexTest extends SymfonyLightCodeInsightFixtureTestCase {
14+
15+
public void setUp() throws Exception {
16+
super.setUp();
17+
myFixture.copyFileToProject("classes.php");
18+
}
19+
20+
public String getTestDataPath() {
21+
return new File(this.getClass().getResource("fixtures").getFile()).getAbsolutePath();
22+
}
23+
24+
public void testThatControllerActionsForBundlesAreGenerated() {
25+
Collection<ControllerAction> actions = new ControllerIndex(getProject()).getActions();
26+
27+
assertNotNull(
28+
actions.stream().findFirst().filter(action -> "FooBundle:Foo:foo".equals(action.getShortcutName()))
29+
);
30+
31+
assertNotNull(
32+
actions.stream().findFirst().filter(action -> "FooBundle:Apple\\Foo:foo".equals(action.getShortcutName()))
33+
);
34+
35+
assertNotNull(
36+
actions.stream().findFirst().filter(action -> "FooBundle:Apple\\Bar\\Foo:foo".equals(action.getShortcutName()))
37+
);
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Symfony\Component\HttpKernel\Bundle{
4+
interface Bundle {}
5+
}
6+
7+
namespace FooBundle {
8+
class FooBundle implements \Symfony\Component\HttpKernel\Bundle\Bundle {}
9+
}
10+
11+
namespace FooBundle\Controller {
12+
class FooController {
13+
public function fooAction() {}
14+
}
15+
}
16+
17+
namespace FooBundle\Controller\Apple {
18+
class FooController {
19+
public function fooAction() {}
20+
}
21+
}
22+
23+
namespace FooBundle\Controller\Apple\Bar {
24+
class FooController {
25+
public function fooAction() {}
26+
}
27+
}

0 commit comments

Comments
 (0)