I have a Yaml bootloader that loads additional configuration items for a βprofileβ (where one application can use different profiles, for example, for different local editions of the same site).
My bootloader is very simple:
# YamlProfileLoader.php use Symfony\Component\Config\Loader\FileLoader; use Symfony\Component\Yaml\Yaml; class YamlProfileLoader extends FileLoader { public function load($resource, $type = null) { $configValues = Yaml::parse($resource); return $configValues; } public function supports($resource, $type = null) { return is_string($resource) && 'yml' === pathinfo( $resource, PATHINFO_EXTENSION ); } }
The loader is used in a more or less similar way (the bit is simplified because there is caching too):
$loaderResolver = new LoaderResolver(array(new YamlProfileLoader($locator))); $delegatingLoader = new DelegatingLoader($loaderResolver); foreach ($yamlProfileFiles as $yamlProfileFile) { $profileName = basename($yamlProfileFile, '.yml'); $profiles[$profileName] = $delegatingLoader->load($yamlProfileFile); }
So, the Yaml file that it parses:
Currently, the resulting array contains literally '%profiles.germany.host_name%' for the array key 'hostname' .
So, how can I parse the% parameters to get the actual parameter values?
I made my way through Symfony 2 code and documents (and this SO question) and cannot find where this is done in the structure itself. probably write your own parameter parser - get the parameters from the kernel, find the lines% foo% and look-up / replace ... but if the component is ready to use, I prefer to use this.
To give a little more background, why can't I just include it in the main config.yml file: I want to be able to load app/config/profiles/*.yml , where * is the profile name, and I use my own loader for this . If there is a way for wildcard import configuration files, then this may also work for me.
Note: 2.4 is currently in use, but is about ready to upgrade to 2.5 if that helps.