コード例 #1
0
ファイル: Module.php プロジェクト: communityii/yii2-common
 /**
  * Sets the value of a component property.
  * This method will check in the following order and act accordingly:
  *
  *  - a property defined by a setter: set the property value
  *  - an event in the format of "on xyz": attach the handler to the event "xyz"
  *  - a behavior in the format of "as xyz": attach the behavior named as "xyz"
  *  - a property of a behavior: set the behavior property value
  *  - a element defined in `_static` property array
  *  - if `static::MAGIC_PROPERTIES` is `true`, add item to `_static` property array
  * 
  * @param type $name
  * @param type $value
  * @throws UnknownPropertyException
  */
 public function __set($name, $value)
 {
     try {
         parent::__set($name, $value);
     } catch (UnknownPropertyException $e) {
         if (isset($this->_static[$name]) || static::MAGIC_PROPERTIES) {
             if (static::MAGIC_PROPERTIES) {
                 Yii::trace('magic property set (' . $name . '=' . $value . ')', __CLASS__);
             }
             $this->_static[$name] = $value;
         } else {
             throw $e;
         }
     }
 }