Reputation: 1468
With Symfony 4, I want to load routes.yaml
in my custom external Bundle. I created class extended Load
but it's not loaded ( Resource : https://symfony.com/doc/current/routing/custom_route_loader.html#more-advanced-loaders )
namespace GaylordP\FineUploaderBundle\Routing;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\RouteCollection;
class AdvancedLoader extends Loader
{
public function load($resource, $type = null): RouteCollection
{
$routes = new RouteCollection();
$importedRoutes = $this->import(
'@FineUploaderBundle/Resources/config/routes.yaml',
'yaml'
);
$routes->addCollection($importedRoutes);
dump($routes); // not executed
exit; // not executer
return $routes;
}
public function supports($resource, $type = null): bool
{
return 'advanced_extra' === $type;
}
}
Upvotes: 1
Views: 2231
Reputation: 1679
https://symfony.com/doc/current/bundles/override.html#routing
Routing is never automatically imported in Symfony. If you want to include the routes from any bundle, then they must be manually imported from somewhere in your application (e.g. config/routes.yaml).
Upvotes: 1
Reputation: 10404
You could simply add the import in the main existing config/routes.yaml
file :
fineuploaderbundle:
resource: "@FineUploaderBundle/Resources/config/routes.yaml"
Upvotes: 5