My application consists of several packages, which are called HelloWorldAdminBundle, HelloWorldUserBundle, HelloWorldDemoBundle. This leads to the root of the configuration, for example hello_world_demo, hello_world_userand hello_world_demo. I want the configuration roots of my packages to be helloworld_demo, helloworld_userand helloworld_admin. At this point, I must mention that this is not a real technical problem, but rather an aesthetic problem.
I tried to implement a custom extension and register it in the Bundle:
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->registerExtension(new HelloworldDemoExtension());
}
Expansion:
...
class HelloworldDemoExtension extends Extension
{
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');
}
public function getAlias()
{
return 'hello_world_demo';
}
}
and finally, the configuration:
...
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('helloworld_demo');
...
return $treeBuilder;
}
}
I followed the instructions How to open a semantic configuration for the Bundle , however, when I add an element to config.yml, I get the following error:
There is no extension able to load the configuration for "helloworld_demo"
source