HelloWorldAdminBundle
私のアプリケーションは、、、HelloWorldUserBundle
のような名前の複数のバンドルで構成されていますHelloWorldDemoBundle
。hello_world_demo
これにより、、、などの構成ルートが作成されhello_world_user
ますhello_world_demo
。バンドルの構成ルートは、、およびである必要がhelloworld_demo
ありhelloworld_user
ますhelloworld_admin
。その時点で、これは実際には技術的な問題ではなく、より美的な問題であることに言及する必要があります。
カスタム拡張機能を実装して、バンドルに登録しようとしました。
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;
}
}
バンドルのセマンティック構成を公開する方法の指示に従いましたが、アイテムを追加するとconfig.yml
、次のエラーが発生します。
There is no extension able to load the configuration for "helloworld_demo"