Zend_Config::__set PHP Метод

__set() публичный Метод

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
Результат void
    public function __set($name, $value)
    {
        if ($this->_allowModifications) {
            if (is_array($value)) {
                $this->_data[$name] = new self($value, true);
            } else {
                $this->_data[$name] = $value;
            }
            $this->_count = count($this->_data);
        } else {
            /** @see Zend_Config_Exception */
            require_once 'Zend/Config/Exception.php';
            throw new Zend_Config_Exception('Zend_Config is read only');
        }
    }

Usage 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');
     }
 }