Skip to content

Commit ac28b6e

Browse files
authored
Merge pull request #1272 from Haehnchen/feature/1271-symfony-43-route-default
Symfony 4.3: Support "Always Include Route Default Values" parameter syntax #1271
2 parents 1443ae5 + 55affe8 commit ac28b6e

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public Set<String> getVariables() {
8484
// possible fallback
8585
// /hello/{foo}/{foo1}/bar
8686
Set<String> hashSet = new TreeSet<>();
87-
Matcher matcher = Pattern.compile("\\{(\\w+)}").matcher(this.path);
87+
Matcher matcher = Pattern.compile("\\{!?(\\w+)}").matcher(this.path);
8888
while(matcher.find()){
8989
hashSet.add(matcher.group(1));
9090
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/dict/StubIndexedRoute.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* @author Daniel Espendiller <daniel@espendiller.net>
1616
*/
17-
public class StubIndexedRoute implements RouteInterface, Serializable{
17+
public class StubIndexedRoute implements RouteInterface, Serializable {
1818

1919
@NotNull
2020
private final String name;

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/routing/RouteTest.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void testIndexNullable() {
3535

3636
@Test
3737
public void testControllerNullable() {
38-
assertEquals(null, new Route("foo", new HashSet<>(), new HashMap<String, String>() {{
38+
assertNull(new Route("foo", new HashSet<>(), new HashMap<String, String>() {{
3939
put("_controller", null);
4040
}}, new HashMap<>(), new ArrayList<>()).getController());
4141

@@ -47,10 +47,24 @@ public void testControllerNullable() {
4747
@Test
4848
public void testPathVariables() {
4949
StubIndexedRoute route = new StubIndexedRoute("foobar");
50-
route.setPath("/foo/{foo}/{foobar}/bar");
50+
route.setPath("/foo/{foo}/{foobar}/{#foo1}/{|foo2}/bar");
5151

52-
assertTrue("foobar",
53-
new Route(route).getVariables().containsAll(Arrays.asList("foo", "foobar"))
52+
Set<String> variables = new Route(route).getVariables();
53+
assertEquals(2, variables.size());
54+
assertTrue("foobar", variables.containsAll(Arrays.asList("foo", "foobar")));
55+
}
56+
57+
@Test
58+
public void testPathVariablesForDefault() {
59+
StubIndexedRoute route = new StubIndexedRoute("foobar");
60+
route.setPath("/foo/{!foo}/{!foobar}//{Foobar2}bar");
61+
62+
Set<String> variables = new Route(route).getVariables();
63+
64+
assertEquals(3, variables.size());
65+
assertTrue(
66+
"foobar",
67+
variables.containsAll(Arrays.asList("foo", "foobar", "Foobar2"))
5468
);
5569
}
5670
}

0 commit comments

Comments
 (0)