__set() public method

Only allow setting of a property if $allowModifications was set to true on construction. Otherwise, throw an exception.
public __set ( string $name, mixed $value ) : void
$name string
$value mixed
return void
Example #1
0
 /**
  * Sets value method
  *
  * @param string $name
  * @param mixed $value
  */
 public function __set($name, $value)
 {
     if ($this->_allowModifications) {
         if (is_array($value)) {
             $value = new $this->_defaultConfigClass($value, true);
         }
         if ($name === null) {
             $this->_data[] = $value;
             $this->_count = count($this->_data);
         } else {
             $this->_dirtyFields[] = $name;
             parent::__set($name, $value);
         }
     } else {
         throw new Enlight_Config_Exception('Enlight_Config is read only');
     }
 }