How to load route from a deactivable bundle

108 Views Asked by At

After many searches, I don't find how to load dynamically routes from a bundle that could be "deactivated". In a legacy project using Symfony 4.4, a custom script could enable or disable a bundle. This script only comment lines in AppKernel.php. Based on that, my activated Bundle must define its own routes. I tried using the Custom Route Loader and insert this in my main route.yml:

my_bundle:
    resource: .
    type: my_bundle_routes

But when I disable my bundle, I got this error :

Error Output: ================ 13:25:04 ERROR [console] Error thrown while running command "cache:warmup --env=dev". Message: "Cannot load resource ".". Make sure there is a loader supporting the "my_bundle_routes" type." ["exception" => Symfony\Component\Config\Exception\LoaderLoadException { …},"command" => "cache:warmup --env=dev","message" => "Cannot load resource ".". Make sure there is a loader supporting the "my_bundle_routes" type."]

In Loader.php line 73: Cannot load resource ".". Make sure there is a loader supporting the "my_bundle_routes" type.

My loader is tag as "routing.loader" and I'm using the Extension file to load dynamically my services.

Is there a way to make Dynamic route loader that load correctly routes when my Bundle is activated and do not register correctly routes when I deactivate the Bundle?

Thanks in advance.

0

There are 0 best solutions below