title: Get Symfony2 environment in bundle Extension
body: <p>In my Symfony2 bundle extension my <code>services.yml</code> is being loaded</p>
  
  <pre><code>$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
  $loader-&gt;load('services.yml');
  </code></pre>
  
  <p>However I want to load different services config per environment (eg: a different one for tests).</p>
  
  <p>Most of the examples I've found for getting the current environment is for access within Controllers (eg: <code>$this-&gt;get('kernel')-&gt;getEnvironment()</code>), however Controller based access is not possible in Extensions.</p>
  
  <p>According to <a href="https://stackoverflow.com/questions/13307815/twig-extension-symfony2-environment">Twig extension - symfony2 environment</a> the environment can be constructor injected however I'm not sure how my bundle extension is registered/instantiated by Symfony so not sure how to have the enviroment injected (the only references I find via grep are in the cache files, which isn't too helpful).</p>
  
  <p>How can I either specify a different services YAML file to be loaded per env in config, or at least find out the environment so that I can code my Extension class to load the correct file?</p>