Symfony2指定捆绑包的未声明配置

Symfony2指定捆绑包的未声明配置,symfony,Symfony,我想在我的包中注入配置。我的配置如下所示: osc_storage: storages: image: adapter: aws_s3 options: option1: 'test' option2: 'test' ... 基本上,我想要的是,不要定义选项字段将包含的内容,而只是将其注入。在我的configTreeBuilde

我想在我的包中注入配置。我的配置如下所示:

osc_storage:
    storages:
        image:
            adapter: aws_s3
            options:
                option1: 'test'
                option2: 'test'
                ...
基本上,我想要的是,不要定义
选项
字段将包含的内容,而只是将其注入。在我的configTreeBuilder中,我有以下内容:

public function getConfigTreeBuilder()
{
    $treeBuilder = new TreeBuilder();
    $rootNode = $treeBuilder->root('osc_storage');


    // Here you should define the parameters that are allowed to
    // configure your bundle. See the documentation linked above for
    // more information on that topic.

    $rootNode
        ->children()
            ->arrayNode('storages')
                ->prototype('array')
                    ->children()
                        ->scalarNode('adapter')->end()
                        ->arrayNode('options')
                            ->prototype('array')
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ->end();

    return $treeBuilder;
}
但是,我得到以下错误:

Invalid type for path "osc_storage.storages.image.options.option1". Expected array, but got string

有没有办法指定您知道这是一个关联数组,但不想指定每个节点?

您可以这样做:

 ->arrayNode('storages')
     ->prototype('array')
         ->children()
             ->scalarNode('adapter')->end()
             ->variableNode('options')->end()
         ->end()
     ->end()
 ->end()