我想检查配置对象中是否有某个属性,如果没有,请在bootstrap中为配置对象添加新属性。怎么可能呢?
示例: -
$options['allowModifications'] = true;
$config = new Zend_Config_Ini( APPLICATION_PATH . '/configs/clientsettings.ini', null, $options);
if (!isset($config->offers->default)) {
$config->offers->default = "Best Available Rate";
}
Zend_Registry::set('clientSettings', $config);
答案 0 :(得分:1)
我意识到了一个解决方案,
$options['allowModifications'] = true;
$config = new Zend_Config_Ini( APPLICATION_PATH . '/configs/clientsettings.ini', null, $options);
if (!isset($config->offers->default)) {
$offers = ['default' => "Best Available Rate"];
$config->offers = $offers;
}
Zend_Registry::set('clientSettings', $config);
但最后我认为这不是一个好主意,允许修改配置对象。