title: Symfony custom route loader : import error
body: <p>I'm trying to dynamically load yml routing files from different bundles according to values in my DB. I've followed the <a href="http://symfony.com/doc/current/cookbook/routing/custom_route_loader.html" rel="nofollow">cookbook</a> 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 <em>routing.yml</em> file.</p>
  
  <p>I've created a service to load the resources :</p>
  
  <pre><code>class ExtraLoader implements LoaderInterface
  {
      private $loaded = false;
  
      public function load($resource, $type = null)
      {
          if (true === $this-&gt;loaded) {
              throw new \RuntimeException('Do not add the "extra" loader twice');
          }
  
          $loader = new AdvancedLoader($this-&gt;getResolver());
          $routes = new RouteCollection();
  
          $route = $loader-&gt;import('@ERPExsecBBundle/Resources/config/routing.yml');
          $route-&gt;addPrefix('/Production/');
          $routes-&gt;addCollection($route);
  
          $this-&gt;loaded = true;
  
          return $routes;
      }
  
      [...]
  }
  </code></pre>
  
  <p>And an advanced loader as described in the cookbook :</p>
  
  <pre><code>class AdvancedLoader extends Loader
  {
      public function __construct($resolver) {
          $this-&gt;resolver = $resolver;
      }
  
      public function load($resource, $type = null)
      {
          $collection = new RouteCollection();
          $type = 'yaml';
          $importedRoutes = $this-&gt;import($resource, $type);
          $collection-&gt;addCollection($importedRoutes);
          return $importedRoutes;
      }
  
      public function supports($resource, $type = null)
      {
          return $type === 'advanced_extra';
      }
  }
  </code></pre>
  
  <p>But I'm getting an error :</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>Why am I getting this error ?</p>