开发者

SF2 : Allow user to configure bundle without checking some part of the bundle configuration

I'm actually developping a symfony 2 bundle. I would like to allow user to configure my bundle with the DIC without checking some part of the bundle configuration.

For example, the user sets this configuration :

root_node:
    node:
        key1: value1
        key2: value2
        key3: value3

And my configuration bundle is set like that :

$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('root_node');

$rootNode
    ->children()
        ->arrayNode('node')->children()->end()
    ->end();

I would like the children nodes of "node" can be configure by the user without been checking by the bundle configuration. I don't know how modify the configuration for this issue开发者_运维百科.


After some reseach on the symfony2 github repository, I found the solution. For the others who want to do the same thing, the solution is :

$rootNode
    ->children()
        ->arrayNode('node')
            ->useAttributeAsKey('node')->prototype('scalar')->end()
        ->end()
    ->end();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜