Exemplo n.º 1
0
 public function __set($name, $value)
 {
     if (array_key_exists($name, $this->_langAttributes)) {
         $this->_langAttributes[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Exemplo n.º 2
0
 public function __set($name, $value)
 {
     if ($name === 'password') {
         $value = CPasswordHelper::hashPassword($value);
     }
     parent::__set($name, $value);
     // TODO: Change the autogenerated stub
 }
Exemplo n.º 3
0
 public function __set($name, $value)
 {
     if (isset($this->_fieldsArias[$name])) {
         parent::__set($this->_fieldsArias[$name], $value);
     } else {
         parent::__set($name, $value);
     }
 }
Exemplo n.º 4
0
 /**
  * PHP setter magic method.
  * This method is overridden so that AR attributes can be accessed like properties.
  * @param string $name property name
  * @param mixed $value property value
  */
 public function __set($name, $value)
 {
     $setter = 'set' . ucfirst($name);
     if (method_exists($this, $setter)) {
         return $this->{$setter}($value);
     }
     parent::__set($name, $value);
 }
Exemplo n.º 5
0
 /**
  * 复杂类型字段赋值实现
  */
 public function __set($name, $value)
 {
     if (in_array($name, $this->complexAttributes())) {
         $value = CJSON::encode($value);
         parent::__set($name, $value);
     } else {
         parent::__set($name, $value);
     }
 }
Exemplo n.º 6
0
 public function __set($name, $value)
 {
     $upper = strtoupper($name);
     if ($this->hasAttribute($upper) || $this->hasRelated($upper)) {
         return parent::__set($upper, $value);
     } else {
         return parent::__set($name, $value);
     }
 }
Exemplo n.º 7
0
 public function __set($name, $value)
 {
     $e;
     try {
         return parent::__set($name, $value);
     } catch (\Exception $ex) {
         $e = $ex;
     }
     $this->dataStore[$name] = $value;
 }
 public function __set($name, $value)
 {
     try {
         parent::__set($name, $value);
         if ($name === 'eav_set_id') {
             $this->refreshEavAttributes();
         }
     } catch (CException $ex) {
         if ($this->setEavAttribute($name, $value) === false) {
             throw $ex;
         }
     }
 }
Exemplo n.º 9
0
 public function __set($name, $val)
 {
     try {
         return parent::__set($name, $val);
     } catch (CException $e) {
         $method_name = StringHelper::underscoreToCamelcase($name);
         $method_name = 'set' . ucfirst($method_name);
         if (method_exists($this, $method_name)) {
             return $this->{$method_name}($val);
         } else {
             throw new CException($e->getMessage());
         }
     }
 }
Exemplo n.º 10
0
 /**
  * If an array of arrays is passed for a HAS_MANY relation attribute, will create appropriate objects
  * to assign to the attribute. Sets up the afterSave method to saves these objects if they have validated.
  *
  * NOTE once a property is set, this magic method will not be called by php for setting it again, unless the property
  * is unset first.
  *
  * @param string $name
  * @param mixed $value
  * @throws Exception
  * @return mixed|void
  */
 public function __set($name, $value)
 {
     // Only perform this override if turned on for the given model
     if ($this->auto_update_relations && is_array($value) && count($value) && isset($this->getMetaData()->relations[$name])) {
         $rel = $this->getMetaData()->relations[$name];
         $cls = get_class($rel);
         if ($cls == self::HAS_MANY || $cls == self::MANY_MANY) {
             $rel_cls = $rel->className;
             $pk_attr = $rel_cls::model()->getMetaData()->tableSchema->primaryKey;
             // not supporting composite primary keys at this point
             if (is_string($pk_attr)) {
                 $m_set = array();
                 foreach ($value as $v) {
                     if (is_array($v)) {
                         // looks like a list of attribute values, try to find or instantiate the classes
                         if (array_key_exists($pk_attr, $v) && isset($v[$pk_attr])) {
                             $m = $rel_cls::model()->findByPk($v[$pk_attr]);
                         } else {
                             $m = new $rel_cls();
                         }
                         $m->attributes = array_merge($this->getRelationsDefaults($name), $v);
                         // set foreign key on the related object
                         $m->{$rel->foreignKey} = $this->getPrimaryKey();
                     } elseif (is_object($v)) {
                         $m = $v;
                     } else {
                         // try to find the instance
                         if (!($m = $rel_cls::model()->findByPk($v))) {
                             throw new Exception("Unable to understand value " . print_r($v, true) . " for {$name}");
                         }
                     }
                     $m_set[] = $m;
                 }
                 // reset the value for it to be set by parent method
                 $value = $m_set;
             }
         }
     }
     parent::__set($name, $value);
 }
Exemplo n.º 11
0
 public function __set($name, $value)
 {
     $this->initRelation();
     switch (true) {
         case Helper::isLastString($name, 'PageSize'):
             $name = substr_replace($name, '', -8);
             $this->__pageSize[$name] = $value;
             break;
         case Helper::isLastString($name, 'Insert'):
             $name = substr_replace($name, '', -6);
             if (isset($this->__relations[$name])) {
                 $this->__relInsert[$name] = $value;
             }
             break;
         case Helper::isLastString($name, 'Update'):
             $name = substr_replace($name, '', -6);
             if (isset($this->__relations[$name])) {
                 $this->__relUpdate[$name] = $value;
             }
             break;
         case Helper::isLastString($name, 'Delete'):
             $name = substr_replace($name, '', -6);
             if (isset($this->__relations[$name])) {
                 $this->__relDelete[$name] = $value;
             }
             break;
         case isset($this->__relations[$name]):
             $this->__relations[$name] = $value;
             break;
         default:
             try {
                 parent::__set($name, $value);
             } catch (Exception $e) {
                 $this->__tempVar[$name] = $value;
             }
             break;
     }
 }
Exemplo n.º 12
0
 public function __set($name, $value)
 {
     if ($name === 'attributes') {
         foreach ($value as $key => $val) {
             if (strpos($key, '.') !== false) {
                 $parts = explode('.', $key);
                 $relation = $this->getActiveRelation($parts[0]);
                 $className = $relation->className;
                 $model = new $className();
                 if ($model->hasAttribute($parts[1]) || $model->hasProperty($parts[1])) {
                     $this->Search[$parts[0]][$parts[1]] = $val;
                 }
             }
         }
     }
     parent::__set($name, $value);
 }
 public function __set($name, $value)
 {
     $flags = $this->cachedFlags();
     if (strncasecmp($name, $this->namePrefix, 2) === 0) {
         $name = substr(strtolower($name), strlen($this->namePrefix));
         if (isset($flags[$name])) {
             $this->setFlag($flags[$name], $value);
         }
     } else {
         parent::__set($name, $value);
     }
 }
Exemplo n.º 14
0
 public function __set($name, $value)
 {
     $isSerialized = $this->isSerializedAttr($name);
     if ($isSerialized) {
         $this->getData()->{$name} = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Exemplo n.º 15
0
 /**
  * @see CActiveRecord::__set()
  */
 public function __set($name, $value)
 {
     if ($this->getAttribute($name) == $value) {
         return;
     }
     parent::__set($name, $value);
     if (!$this->getIsNewRecord() && $this->hasAttribute($name)) {
         $this->_dirtykeys[] = $name;
         $this->_isdirty = true;
     }
 }
 /**
  * Allow queuing up the MANY_MANY relation changes set using the $model->relation method
  * @param $name
  * @param $value
  */
 public function __set($name, $value)
 {
     if (isset($this->getMetaData()->relations[$name])) {
         if ($this->getManyManyRelation($name)) {
             // if this is a many_many relation
             $this->setAllRelated($name, $value);
             // set up the keys to add and remove
         }
     }
     parent::__set($name, $value);
 }