I've spent the last day trying to figure out why routes could not be dumped anymore to JS in my app.
I'm hoping to save hours of trouble for other developers who would encounter the exact same issue.
The exposed routes defined in app/config/config.yml are now transformed into a regular expression:
(?P<default>route_1|route_2)
The problem when using JMSI18nRoutingBundle is that the names of the routes are locale-prefixed, so that in the loop through all routes:
foreach ($collection->all() as $name => $route) {
The variable $name would not be route_1 or route_2, such as defined in app/config/config.yml, but rather en__RG__route_1 or en__RG__route_2.
So when populating the $matches array using the original routes names and then attempting to get their corresponding domain using the locale-prefixed routes names, well, that returns null and continues the loop:
After some thoughts, I've stumbled upon a very easy solution consisting in adapting the routes defined in app/config/config.yml so that they would be used as locale-prefixed in the loop!
Tada :)
I hope that it's the right place to inform about this issue, please let me know otherwise, thank you.
I've spent the last day trying to figure out why routes could not be dumped anymore to JS in my app. I'm hoping to save hours of trouble for other developers who would encounter the exact same issue.
exposed domain feature introduced in FOSJsRoutingBundle 2.3.0 unfortunately prevents dumping JMSI18nRoutingBundle internationalized routes.
The exposed routes defined in
app/config/config.yml
are now transformed into a regular expression:The problem when using JMSI18nRoutingBundle is that the names of the routes are locale-prefixed, so that in the loop through all routes:
The variable
$name
would not beroute_1
orroute_2
, such as defined inapp/config/config.yml
, but ratheren__RG__route_1
oren__RG__route_2
.So when populating the
$matches
array using the original routes names and then attempting to get their corresponding domain using the locale-prefixed routes names, well, that returnsnull
and continues the loop:After some thoughts, I've stumbled upon a very easy solution consisting in adapting the routes defined in
app/config/config.yml
so that they would be used as locale-prefixed in the loop!Tada :)
I hope that it's the right place to inform about this issue, please let me know otherwise, thank you.