我的应用程序由多个bundle组成,它们的名称类似于
我尝试实现一个自定义扩展并在bundle中注册它:
最后是配置部分:
我遵循了如何为Bundle公开一个语义化配置的指南,但是当我在
HelloWorldAdminBundle
、HelloWorldUserBundle
、HelloWorldDemoBundle
。这会导致一个配置根目录,如hello_world_demo
、hello_world_user
和hello_world_demo
。我希望我的bundles的配置根是 helloworld_demo
, helloworld_user
和 helloworld_admin
。此时我必须提到,这不是一个技术上的问题,而更像是一个审美问题。我尝试实现一个自定义扩展并在bundle中注册它:
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->registerExtension(new HelloworldDemoExtension());
}
这个扩展:
...
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';
}
}
最后是配置部分:
...
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('helloworld_demo');
...
return $treeBuilder;
}
}
我遵循了如何为Bundle公开一个语义化配置的指南,但是当我在
config.yml
中添加一个项目时,出现了以下错误:There is no extension able to load the configuration for "helloworld_demo"
CMSIP2LocationBundle
。 - tftd