简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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