Zend_Config::setReadOnly PHP Method

setReadOnly() public method

Prevent any more modifications being made to this instance. Useful after merge() has been used to merge multiple Zend_Config objects into one object which should then not be modified again.
public setReadOnly ( )
    public function setReadOnly()
    {
        $this->_allowModifications = false;
        foreach ($this->_data as $key => $value) {
            if ($value instanceof Zend_Config) {
                $value->setReadOnly();
            }
        }
    }

Usage Example

Example #1
0
 /**
  * Combine the static info found in application.ini with the
  * dynamic info found in the Info table.
  *
  * @return void
  */
 protected function _initConfig()
 {
     $this->bootstrap('db');
     $this->bootstrap('locale');
     if (!class_exists('Model_Info')) {
         return;
     }
     try {
         $staticConfig = Zend_Registry::get('config');
         $infoModel = $this->_getInfoModel();
         $dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV);
         // Very sneakily bypass 'readOnly'
         if ($staticConfig->readOnly()) {
             $staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true);
         }
         $staticConfig->merge($dynamicConfig);
         $staticConfig->setReadOnly();
         Zend_Registry::set('config', $staticConfig);
     } catch (Exception $e) {
         $msg = $e->getMessage();
         if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false) {
             throw $e;
         }
     }
 }
All Usage Examples Of Zend_Config::setReadOnly