我不确定这是否可能,但是...
zf2 ModuleManager 将按顺序合并模块的所有配置数组,然后合并任何用户定义的配置数组。因此,如果与您$config1
合并,则$config2
得到$merged
.
$config1 = [
'key1' => 1,
'key2' => 2,
'key3' => 3
]
$config2 = [
'key1' => 'different',
'key4' => 4
]
$merged = [
'key1' => 'different',
'key2' => 2
'key3' => 3
'key4' => 4
]
这很好,适用于大多数情况。但是,如果我想删除密钥怎么办?如果我$config1
有如上,并想在$merged
下面创建这个替代,那么应该是什么值$config2
(注意key2
被删除)?
$merged = [
'key1' => 'different',
'key3' => 3
'key4' => 4
]