Same bundle different routes Same bundle different routes symfony symfony

Same bundle different routes


you should use one route but use mkt and crm as a variable.

contact:    path:      /{ prefix }/contact    defaults:  { _controller: YourContactBundle:Contact:contact }

Then in twig or wherever you want

{{ path('contact', { 'prefix': prefix } ) }}

You should retrieve the variable contact by session or by giving parameters to the route.

As it's just some few bundles who are in common, i would recommend to give the parameter.In home of the market app, i would call the contact form by {{ path('contact',{ 'app_prefix' : constant_prefix_mkt} ) }}


You don't want to load all your bundle routing file two times with differents prefix

Try:

app/routing.yml

crm_contact:    path:      /crm/contact    defaults:  { _controller: YourContactBundle:Contact:contact }mkt_contact:    path:      /mkt/contact    defaults:  { _controller: YourContactBundle:Contact:contact }

then in your twig:

{{ path(app.request.attributes.get('_route')) }}