當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。