Symfony 2 bundles have a nice feature for autoloading/extending the application configuration files, such as services.yml. However, this is not true for routing, since i have to manually edit the routing.yml of my application in order to load the routing data from my Bundle (the Controller or the routing.yml itself).
Is it possible to load such routing configuration this seamlessly?
---- EDIT
I ended up doing this, but it's ugly as hell:
<?php
use Symfony\Component\Routing\RouteCollection;
$collection = new RouteCollection();
foreach (glob(__DIR__.'/../../src/Vendor/MySystem/Plugins/*Bundle/Controller/', GLOB_ONLYDIR) as $controller) {
$controller = str_replace(__DIR__.'/../../src/Vendor/MySystem/Plugins/', '', $controller);
$collection->addCollection($loader->import("@$controller"));
}
return $collection;
i think you should look after the "routing.loader" dependency injection tag It let you define a class to define routes with your logic
http://symfony.com/doc/current/reference/dic_tags.html#routing-loader
I think You could also define an dependencyInjection extension in your bundle. In your load method, you can alter the container definitions and so your routes..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With