In my Symfony2 bundle extension my services.yml
is being loaded
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
However I want to load different services config per environment (eg: a different one for tests).
Most of the examples I've found for getting the current environment is for access within Controllers (eg: $this->get('kernel')->getEnvironment()
), however Controller based access is not possible in Extensions.
According to Twig extension - symfony2 environment 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).
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?