本文整理汇总了PHP中CActiveRecordBehavior::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecordBehavior::__set方法的具体用法?PHP CActiveRecordBehavior::__set怎么用?PHP CActiveRecordBehavior::__set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecordBehavior
的用法示例。
在下文中一共展示了CActiveRecordBehavior::__set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
/**
* 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
}
}
示例2: __set
/**
* 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);
}
}
示例3: __set
/**
* 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;
}
}
}
示例4: __set
/**
* 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;
}
}
示例5: __set
public function __set($name, $value)
{
try {
parent::__set($name, $value);
} catch (CException $e) {
if ($this->hasLangAttribute($name)) {
$this->setLangAttribute($name, $value);
} else {
throw $e;
}
}
}
示例6: __set
/**
* 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);
}