私のアプリケーションは、HelloWorldAdminBundle
,HelloWorldUserBundle
、HelloWorldDemoBundle
という名前の複数のバンドルで構成されています。これにより、hello_world_demo
、hello_world_user
、およびhello_world_demo
のような構成ルートが生成されます。バンドルのコンフィグレーションルーツはhelloworld_demo
、helloworld_user
、helloworld_admin
です。その時点では、これは実際には技術的な問題ではなく、審美的な問題であると言わざるを得ない。Symfony2:カスタム設定ルート
私はカスタム拡張を実装し、バンドルに登録しようとしています:
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;
}
}
How to expose a Semantic Configuration for a Bundleの指示、にアイテムを追加するとdocumentationとして
There is no extension able to load the configuration for "helloworld_demo"
素晴らしい!あなたがそれを見つけられたらうれしい –