Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function __set($name, $value)
 {
     if ($this->tryToSetRelation($name, $value)) {
         return;
     }
     parent::__set($name, $value);
 }
Ejemplo n.º 2
0
 public function __set($name, $value)
 {
     if ($name === 'history') {
         return $this->setHistory($value);
     }
     return parent::__set($name, $value);
 }
Ejemplo n.º 3
0
 public function __set($name, $value)
 {
     if (isset($this->_pivotAttributes[$name])) {
         throw new Exception("Attribute '{$name}' is attached from junction table and read-only");
     }
     parent::__set($name, $value);
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function __set($name, $newValue)
 {
     if ($this->hasMetaAttribute($name)) {
         $this->setMeta($name, $newValue);
     } else {
         parent::__set($name, $newValue);
     }
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function __set($name, $value)
 {
     if ($this->_i18n_enabled && in_array($name, $this->_getI18NAttributes())) {
         $this->{$name} = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Ejemplo n.º 6
0
 public function __set($name, $value)
 {
     if (!in_array($name, $this->attributes()) && !empty($this->app->elements[$name]) && ($behavior = $this->getBehavior($this->app->elements[$name]->type)) !== null) {
         return $behavior->setValue($name, $value);
     } else {
         return parent::__set($name, $value);
     }
 }
Ejemplo n.º 7
0
 public function __set($name, $value)
 {
     if (in_array($name, $this->jsonParams)) {
         return $this->setJsonParams($name, $value);
     } else {
         return parent::__set($name, $value);
     }
 }
Ejemplo n.º 8
0
 public function __set($name, $value)
 {
     try {
         parent::__set($name, $value);
     } catch (UnknownPropertyException $e) {
         if (isset($this->_transformers[$name])) {
             $this->_transformers[$name]->transformTo($value);
         } else {
             parent::__set(static::prop2col($name), $value);
         }
     }
 }
 /**
  * Override __get of yii\db\ActiveRecord
  *
  * @param string $name the property name or the event name
  * @param mixed $value the property value
  */
 public function __set($name, $value)
 {
     if ($this->hasAttribute($name)) {
         parent::__set($name, $value);
     } else {
         if ($this->autoSaveMetaFields && !$this->isNewRecord) {
             $this->setMetaAttribute($name, $value);
         } else {
             $this->enqueueMetaUpdate($name, $value);
         }
     }
 }
Ejemplo n.º 10
0
 public function __set($name, $value)
 {
     if (in_array($name, $this->getDefaultFields())) {
         return parent::__set($name, $value);
     }
     if (in_array($name, $this->getSkipFields())) {
         return [];
     }
     $rules = Json::decode($this->rules);
     if (!$rules) {
         $rules = [];
     }
     $rules[$name] = $value;
     $this->rules = Json::encode($rules);
 }
 /**
  * Sets a model attribute.
  *
  * @param string $name attribute name, use dotted notation for structured attributes.
  * @param mixed $value the attribute value. A value of null effectively unsets the attribute.
  */
 public function setAttribute($name, $value)
 {
     try {
         parent::__set($name, $value);
         return;
     } catch (UnknownPropertyException $ignore) {
     }
     $path = explode('.', $name);
     $ref =& $this->_dynamicAttributes;
     // Walk forwards through $path to find the deepest key already set.
     do {
         $key = $path[0];
         if (isset($ref[$key])) {
             $ref =& $ref[$key];
             array_shift($path);
         } else {
             break;
         }
     } while ($path);
     // If the whole path already existed then we can just set it.
     if (!$path) {
         $ref = $value;
         return;
     }
     // There is remaining path so we have to set a new leaf with the first
     // part of the remaining path as key. But first, if there is any path
     // beyond that then we need build an array to set as the new leaf value.
     while (count($path) > 1) {
         $key = array_pop($path);
         $value = [$key => $value];
     }
     $ref[$path[0]] = $value;
 }
Ejemplo n.º 12
0
 public function __set($key, $value)
 {
     if ($key = $this->hasKey($key)) {
         parent::__set($key, $value);
     }
 }
Ejemplo n.º 13
0
 /**
  * @inheritdoc
  */
 public function __set($name, $value)
 {
     if ($name === 'group') {
         $this->_schema = static::$schemaDefinition[$value];
     }
     if ($this->_schema && isset($this->_schema[$name])) {
         $this->_values[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
 public function __set($name, $value)
 {
     $extraFields = $this->parseExtraField();
     if (in_array($name, $extraFields)) {
         $this->_extraFields[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Ejemplo n.º 15
0
 /**
  * PHP setter magic method.
  * This method is overridden so that AR attributes can be accessed like properties,
  * but only if the current model is not read only
  * @param string $name property name
  * @param mixed $value property value
  * @throws Exception if the current record is read only
  */
 public function __set($name, $value)
 {
     if ($this->getReadOnly()) {
         throw new Exception('Attempting to set attribute `' . $name . '` on a read only ' . Tools::getClassName($this) . ' model');
     }
     parent::__set($name, $value);
 }