Reputation: 1054
Is there a way to change the actual settings from service.yml to service.xml into a bundle? When I created the bundle, I defined yml as al standard form, now I need to switch to xml for the reason that there where existing services. xml files which I would like to use without transforming them (which would work as well I think).
Upvotes: 0
Views: 2023
Reputation: 3319
Sure, you can switch to XML if you want to and have the config files in place. Take a look at your bundle's Extension
class located somewhere under YourBundle/DependencyInjection/YourBundleExtension.php
. Its load
method should look like this:
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
To use XML configs instead of YAMLs, instantiate an XmlFileLoader
instead of YamlFileLoader
(the parameters would be the same), and fix the $loader->load()
method call so that it receives your configuration file name:
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}
Upvotes: 8