/** * Make translated attributes writeable, with and without suffix */ public function __set($name, $value) { if (!$this->handlesProperty($name)) { return parent::__set($name, $value); } if (in_array($name, $this->translationAttributes)) { // Without suffix $lang = Yii::app()->language; $withoutSuffix = $name; } else { // With suffix $lang = $this->getLanguageSuffix($name); $withoutSuffix = $this->getOriginalAttribute($name); } $withSuffix = $withoutSuffix . '_' . $lang; if ($lang == Yii::app()->sourceLanguage) { $sourceMessageAttribute = "_" . $withoutSuffix; $this->owner->{$sourceMessageAttribute} = $value; return true; } // Without suffix if (in_array($withoutSuffix, $this->translationAttributes)) { $this->dirtyAttributes[$withSuffix] = $value; // Always store with suffix since we are interested in the language while setting the attribute, not while saving } }
/** * Make translated attributes writeable */ public function __set($name, $value) { if (!$this->disableTranslationModel && in_array($name, $this->translationAttributes)) { $this->getTranslationModel()->{$name} = $value; } else { parent::__set($name, $value); } }
/** * Setter. Returns translated attribute if called for. */ public function __set($name, $value) { try { parent::__set($name, $value); } catch (CException $e) { if (in_array($name, $this->_translatedAttributes)) { $this->{$name} = $value; } else { throw $e; } } }
/** * Make translated attributes writeable without requiring suffix */ public function __set($name, $value) { if (!in_array($name, $this->translationAttributes) && !in_array($name, array_keys($this->multilingualRelations))) { return parent::__set($name, $value); } $translatedAttribute = $name . '_' . Yii::app()->language; if (array_key_exists($translatedAttribute, $this->owner->attributes)) { $this->owner->{$translatedAttribute} = $value; return; } $translatedRelation = $this->generateRelationName($this->multilingualRelations[$name] . '_' . Yii::app()->language); if (array_key_exists($translatedRelation, $this->owner->attributes)) { $this->owner->{$translatedRelation} = $value; return; } }
public function __set($name, $value) { try { parent::__set($name, $value); } catch (CException $e) { if ($this->hasLangAttribute($name)) { $this->setLangAttribute($name, $value); } else { throw $e; } } }
/** * The magic setter, enables resources to be accessed like properties * @param string $name The name of the virtual property * @param mixed $value The value to assign to the virtual property */ public function __set($name, $value) { if (isset($this->attributes[$name])) { if ($value == null) { return $this->attributes[$name]->delete(); } else { return $this->attributes[$name]->add($value); } } return parent::__set($name, $value); }