public function __set($name, $value)
 {
     if (array_key_exists($name, $this->data)) {
         $this->data[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Exemple #2
0
 public function __set($name, $value)
 {
     if ($this->hasAttribute($name, $value)) {
         $this->setAttribute($name, $value);
     } else {
         parent::__set($name, $value);
     }
 }
Exemple #3
0
 public function __set($name, $value)
 {
     if (in_array($name, $this->attributeNames())) {
         $this->_attributes[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Exemple #4
0
 /**
  * @see CComponent::__set()
  * @param string $name
  * @param mixed $value
  * @return mixed
  */
 public function __set($name, $value)
 {
     if (isset($this->_related[$name]) || array_key_exists($name, $this->relations())) {
         return $this->_related[$name] = $value;
     }
     // This might be a little unperformant actually since Yiis own active record detects
     // If an attribute can be set first to ensure speed of accessing local variables...hmmm
     try {
         return parent::__set($name, $value);
     } catch (CException $e) {
         return $this->setAttribute($name, $value);
     }
 }
Exemple #5
0
 public function __set($name, $value)
 {
     if ($this->setAttribute($name, $value) === false) {
         if (isset($this->getMetaData()->relations[$name])) {
             $this->_related[$name] = $value;
         } else {
             parent::__set($name, $value);
         }
     }
 }
Exemple #6
0
 /**
  * PHP setter magic method.
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return mixed
  */
 public function __set($name, $value)
 {
     if ($this->setAttribute($name, $value) === false) {
         parent::__set($name, $value);
     }
 }
 /**
  * @since v1.0.8
  */
 public function __set($name, $value)
 {
     if ($this->hasEmbeddedDocuments() && isset(self::$_embeddedConfig[get_class($this)][$name])) {
         if (is_array($value)) {
             // Late creation of embedded documents on first access
             if (is_null($this->_embedded->itemAt($name))) {
                 $docClassName = self::$_embeddedConfig[get_class($this)][$name];
                 $doc = new $docClassName($this->getScenario());
                 $doc->setOwner($this);
                 $this->_embedded->add($name, $doc);
             }
             return $this->_embedded->itemAt($name)->attributes = $value;
         } else {
             if ($value instanceof EMongoEmbeddedDocument) {
                 return $this->_embedded->add($name, $value);
             }
         }
     } else {
         parent::__set($name, $value);
     }
 }
 /**
  * PHP setter magic method.
  * This method is overridden so that MongoDB document can be accessed like properties.
  * @param string property name
  * @param mixed property value
  */
 public function __set($name, $value)
 {
     if ($name === 'id') {
         $this->_document['_id'] = $value;
     } elseif (array_key_exists($name, $this->_document)) {
         $this->_document[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Exemple #9
0
 /**
  * PHP setter magic method.
  * This method is overridden so that Resource Model attributes can be accessed like properties.
  * @param string $name property name
  * @param mixed $value property value
  * @return void
  */
 public function __set($name, $value)
 {
     if ($this->setAttribute($name, $value) === false) {
         if (isset($this->_links[$name])) {
             $this->_linked[$name] = $value;
         } else {
             parent::__set($name, $value);
         }
     }
 }
 /**
  * Волшебный сеттер
  * @param type $name
  * @param type $value
  */
 public function __set($name, $value)
 {
     // на случай наличия маппинга поля
     $mapping = $this->fieldsMapping();
     if (array_key_exists($name, $mapping)) {
         $name = $mapping[$name];
     }
     // сначала проверим какого типа пришло значение
     // просто setItemValue() вызываем только в случае
     // простых типов данных
     if (!is_object($value)) {
         if ($this->getDbTable()->getFields()->hasElement($name)) {
             $this->getRecord()->setItemValue($name, $value);
             if (!array_key_exists($name, $this->getRecord()->getItems())) {
                 $trace = debug_backtrace();
                 trigger_error('Неопределенное свойство в __set(): ' . $name . ' в файле ' . $trace[0]['file'] . ' на строке ' . $trace[0]['line'], E_USER_NOTICE);
                 return null;
             }
         }
     } else {
         // пришел объект
         // объекты складываем в соответствии с relations()
         if (!array_key_exists($name, $this->relations())) {
             // обратимся к родительскому методу
             parent::__set($name, $value);
             return;
         }
         $relations = $this->relations();
         $relation = $relations[$name];
         // разрешим не указывать
         if (!array_key_exists("storageProperty", $relation)) {
             $relation["storageProperty"] = "_" . $name;
         }
         // определяем, какой тип связи
         if ($relation['relationPower'] == RELATION_HAS_ONE) {
             // сначала кладем объект в приватное свойство
             $private = $relation['storageProperty'];
             $this->{$private} = $value;
             // теперь в поле кладем id объекта
             $field = $relation['storageField'];
             $this->getRecord()->setItemValue($field, $value->getId());
         }
     }
 }
 /**
  * Sets value of a component property.
  * Do not call this method. This is a PHP magic method that we override
  * to allow using the following syntax to set a property or attach an event handler
  * <pre>
  * $this->propertyName=$value;
  * $this->eventName=$callback;
  * </pre>
  * @param string $name the property name or the event name
  * @param mixed  $value the property value or callback
  * @return mixed
  * @throws \CException if the property/event is not defined or the property is read only.
  * @see __get
  */
 public function __set($name, $value)
 {
     if (array_key_exists($name, $this->_attributes)) {
         $this->_attributes[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
Exemple #12
0
 public function __set($name, $value)
 {
     if (isset($this->_attributes[$name])) {
         $this->_values[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }