Example #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);
     }
 }
Example #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;
 }
Example #4
0
 public function setAttribute($name, $value)
 {
     if ($name == "password") {
         $this->markAsPasswordChanged();
     }
     parent::setAttribute($name, $value);
 }
 /**
  * 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();
     }
     //}
 }
Example #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);
 }