我试图公开我的包的一些配置,允许用户定义实体名称和属性与值之间的多个关联。基本上,对于每个实体,用户可以定义排序和订单字段。例如: 对于实体AcmeDemoBundle:Project,我想按"命名DESC"和" id ASC"
acme_demo_default_sort:
entities:
AcmeDemoBundle:Project:
-
property: name
order: desc
-
property: id
order: asc
OR
acme_demo_default_sort:
entities:
AcmeDemoBundle:Project:
name: desc
id: asc
如何为上述配置解析treebuilder?
我能够通过以下示例获得类似的解决方案:
acme_demo_default_sort:
entities:
AcmeDemoBundle:Project:
defaults:
-
property: name
order: desc
$rootNode
->children()
->arrayNode('entities')
->prototype('array')
->children()
->arrayNode('defaults')
->prototype('array')
->children()
->scalarNode('property')->end()
->scalarNode('order')->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
;
感谢。