简体   繁体   English

如何在Zend Framework 1中将新属性附加到配置对象

[英]How to append new attribute to config object in Zend Framework 1

I want to check if available a some attribute in config object and if not, add new attribute to config object in bootstrap. 我想检查配置对象中是否有一些属性,如果没有,请在引导程序中将新属性添加到配置对象中。 How ever is it possible ? 怎么可能?

example :- 例如:

$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);

I realized a solution, 我实现了一个解决方案

$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);

but finally i thought this is not a good idea, allowing config object to modification. 但是最后我认为这不是一个好主意,允许修改配置对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM