I'm trying to dynamically load yml routing files from different bundles according to values in my DB. I've followed the cookbook to create a custom route loader, but I'm having an error when importing a file. I'm working on Symfony 2.3. My routing is working properly when I add the collection manually in the routing.yml file.
I've created a service to load the resources :
class ExtraLoader implements LoaderInterface
{
private $loaded = false;
public function load($resource, $type = null)
{
if (true === $this->loaded) {
throw new \RuntimeException('Do not add the "extra" loader twice');
}
$loader = new AdvancedLoader($this->getResolver());
$routes = new RouteCollection();
$route = $loader->import('@ERPExsecBBundle/Resources/config/routing.yml');
$route->addPrefix('/Production/');
$routes->addCollection($route);
$this->loaded = true;
return $routes;
}
[...]
}
And an advanced loader as described in the cookbook :
class AdvancedLoader extends Loader
{
public function __construct($resolver) {
$this->resolver = $resolver;
}
public function load($resource, $type = null)
{
$collection = new RouteCollection();
$type = 'yaml';
$importedRoutes = $this->import($resource, $type);
$collection->addCollection($importedRoutes);
return $importedRoutes;
}
public function supports($resource, $type = null)
{
return $type === 'advanced_extra';
}
}
But I'm getting an error :
Fatal error: Uncaught exception 'Symfony\Component\Config\Exception\FileLoaderLoadException' with message 'Cannot load resource "@ERPExsecBBundle/Resources/config/routing.yml". Make sure the "ERPExsecBBundle/Resources/config/routing.yml" bundle is correctly registered and loaded in the application kernel class.' in C:\Program Files\wamp\www\alimerp\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\Loader.php on line 77
Why am I getting this error ?