Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to export routes from Symfony2 bundle via DependencyInjection

I want to automatically add routes from my bundle without adding a link to my bundle's routing scheme into routing.yml. For example, this can be admin's bundle. Each application that use this bundle will get special /admin/xxx routes without manual editing of routing scheme.

For services it's pretty easy with overriding of Extension->load() method, but for routing I couldn't find a solution.

How can I implement desired feature?

like image 422
lisachenko Avatar asked Dec 08 '25 03:12

lisachenko


1 Answers

At the moment you can't easily hook into the routing like that from a Bundle, that's why the framework stuff itself like the profiler and web debug toolbar have to be included from the routing_dev.yml file.

However it would be doable I believe to add an event dispatched when the routing is parsed I guess, allowing bundles to hook into it to add their own routes to the RouteCollection. I created an issue to that effect on the Symfony tracker.

like image 121
Seldaek Avatar answered Dec 10 '25 16:12

Seldaek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!