【发布时间】:2020-10-16 11:57:43
【问题描述】:
我有以下配置:
$treeBuilder = new TreeBuilder('rest_api');
$treeBuilder->getRootNode()
->addDefaultsIfNotSet()
->children()
->arrayNode('exceptions')
->defaultValue([])
->arrayPrototype()
->scalarPrototype()
->end()
->end()
->end()
->end();
以下是 2 个不同捆绑包中的 2 个文件:
rest_api:
exceptions:
404:
- UserNotFoundException
400:
- InvalidCredentailsException
rest_api:
exceptions:
404:
- NotFoundHttpException
400:
- SomeRandomException
- OtherRandomException
我希望结果如下所示:
^ array:1 [
"exceptions" => array:4 [
404 => array:1 [
0 => "NotFoundHttpException"
1 => "UserNotFoundException"
]
400 => array:2 [
0 => "SomeRandomException"
1 => "OtherRandomException"
=> "InvalidCredentailsException"
]
]
]
但是我得到了这个:
^ array:1 [
"exceptions" => array:4 [
404 => array:1 [
0 => "NotFoundHttpException"
]
400 => array:2 [
0 => "SomeRandomException"
1 => "OtherRandomException"
]
405 => array:1 [
0 => "UserNotFoundException"
]
406 => array:1 [
0 => "InvalidCredentailsException"
]
]
]
如何启用 arrayPrototypes 的深度合并?
我尝试同时使用整数和字符串作为键名,将键更改为非数字:c404、c400,以及文档中的两种设置:performNoDeepMerging 和 cannotBeOverwritten,但似乎都不起作用.
我需要的是 performDeepMerging 选项或类似的东西,但我在任何地方都看不到它。
【问题讨论】:
标签: symfony configuration