예제 #1
0
 /**
  * need protected $_attributes
  *
  * @param string $name_key
  * @param mixed $value
  * @return bool
  */
 public function setAttribute($name_key, $value)
 {
     $pos = strpos($name_key, '[');
     if ($pos) {
         $key = substr($name_key, $pos + 1, -1);
         $name = substr($name_key, 0, $pos);
         if (property_exists($this, $name)) {
             $this->{$name}[$key] = $value;
         } elseif (isset($this->getMetaData()->columns[$name])) {
             $this->_attributes[$name][$key] = $value;
         } else {
             return false;
         }
         return true;
     } else {
         return parent::setAttribute($name_key, $value);
     }
 }
예제 #2
0
 public function setAttribute($name, $value)
 {
     parent::setAttribute(DataHelper::camelToSnake($name), $value);
 }
 public function setAttribute($name, $value)
 {
     if (parent::setAttribute($name, $value)) {
         if ($name === 'eav_set_id') {
             $this->refreshEavAttributes();
         }
         return true;
     }
     return false;
 }
예제 #4
0
파일: User.php 프로젝트: kittolau/gcm
 public function setAttribute($name, $value)
 {
     if ($name == "password") {
         $this->markAsPasswordChanged();
     }
     parent::setAttribute($name, $value);
 }
예제 #5
0
 /**
  * This method is used to at create/copy or move. If the last $inherit attribute is true
  * the nodes under current and current also will inherit the values from the new parent.
  * @param CActiveRecord $current node that is created/copied or moved
  * @param CActiveRecord $parent the new parent in either senario
  */
 public function inheritvalues($current, $parent)
 {
     //        $differentparent = $parent->getAttribute($this->identity)!=$current->parent()->getAttribute($this->identity);
     //        if ( $differentparent ) {
     foreach ($this->inherit as $attr) {
         $current->setAttribute($attr, $parent->getAttribute($attr));
     }
     $current->saveNode();
     $descendants = $current->descendants()->findAll();
     foreach ($descendants as $i => $node) {
         foreach ($this->inherit as $attr) {
             $node->setAttribute($attr, $parent->getAttribute($attr));
         }
         $node->saveNode();
     }
     //}
 }
예제 #6
0
 /**
  * Sets the attribute value.
  *
  * @param string $name the attribute name
  * @param mixed $value the attribute value
  * @param bool $cast whether to cast the value to the appropriate type, defaults to true
  *
  * @return boolean whether the attribute exists and the assignment is conducted successfully
  */
 public function setAttribute($name, $value, $cast = true)
 {
     if ($cast) {
         if (property_exists($this, $name)) {
             $value = $this->castAttribute($name, $value);
         } elseif (isset($this->getMetaData()->columns[$name])) {
             $value = $this->castAttribute($name, $value);
         }
     }
     return parent::setAttribute($name, $value);
 }