当前位置: 首页>>代码示例>>PHP>>正文


PHP CActiveRecordBehavior::__set方法代码示例

本文整理汇总了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
     }
 }
开发者ID:neam,项目名称:yii-i18n-attribute-messages,代码行数:29,代码来源:I18nAttributeMessagesBehavior.php

示例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);
     }
 }
开发者ID:mikehaertl,项目名称:translatable,代码行数:11,代码来源:Translatable.php

示例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;
         }
     }
 }
开发者ID:kostya1017,项目名称:our,代码行数:15,代码来源:MultilangVirtualAttributesBehavior.php

示例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;
     }
 }
开发者ID:neam,项目名称:yii-i18n-columns,代码行数:19,代码来源:I18nColumnsBehavior.php

示例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;
         }
     }
 }
开发者ID:DarkAiR,项目名称:test,代码行数:12,代码来源:MultilingualBehavior.php

示例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);
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:16,代码来源:AResourceful.php


注:本文中的CActiveRecordBehavior::__set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。