FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

Route does not exist with localized path #354

Open vklepper opened 5 years ago

vklepper commented 5 years ago

I got an error when i try to generate a route with localized path :

shop_article:
  controller: App\Controller\ShopController::showArticle
  path:
    fr: boutique/article/{slug}-{id}
    en: shop/article/{slug}-{id}
    de: shop/artikel/{slug}-{id}
  requirements:
    slug: .+
    id: \d+
  options:
    expose: true

if I remove all the localized path and keep only one like that path: shop/article/{slug}-{id} , it's working. What am I doing wrong?

florianajir commented 5 years ago

try this command and check the route name and the required params to generate the route php bin/console debug:router

vklepper commented 5 years ago

omg you juste save me ! For the record, I try to generate the route by this name but without the .locale

  shop_category.fr                     ANY      ANY      ANY    /boutique/categories/{id}-{slug}                
  shop_category.en                     ANY      ANY      ANY    /shop/categories/{id}-{slug}                    
  shop_category.de                     ANY      ANY      ANY    /shop/kategorien/{id}-{slug}  
const locale = '{{ app.request.locale }}';
Routing.generate('shop_article.' + locale, {id: article.id, slug: article.slug})

Thx @florianajir ! :+1:

tobias-93 commented 5 years ago

Is this still an issue with #334 merged?