當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AttributeBehavior::init方法代碼示例

本文整理匯總了PHP中yii\behaviors\AttributeBehavior::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP AttributeBehavior::init方法的具體用法?PHP AttributeBehavior::init怎麽用?PHP AttributeBehavior::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\behaviors\AttributeBehavior的用法示例。


在下文中一共展示了AttributeBehavior::init方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute], BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute];
     }
 }
開發者ID:cmsgears,項目名稱:module-core,代碼行數:7,代碼來源:AuthorBehavior.php

示例2: init

 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->phoneAttribute, BaseActiveRecord::EVENT_AFTER_FIND => $this->phoneAttribute];
     }
 }
開發者ID:borales,項目名稱:yii2-phone-input,代碼行數:7,代碼來源:PhoneInputBehavior.php

示例3: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_AFTER_VALIDATE => [$this->attribute], BaseActiveRecord::EVENT_AFTER_FIND => [$this->attribute]];
     }
 }
開發者ID:vaseninm,項目名稱:yii2-hstore,代碼行數:10,代碼來源:HstoreBehavior.php

示例4: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->attribute !== null) {
         $this->attributes[BaseActiveRecord::EVENT_BEFORE_INSERT][] = $this->attribute;
     }
     parent::init();
 }
開發者ID:mdmsoft,項目名稱:yii2-autonumber,代碼行數:10,代碼來源:Behavior.php

示例5: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => $this->compiledAttribute, BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->compiledAttribute];
     }
 }
開發者ID:hauntd,項目名稱:help-center,代碼行數:10,代碼來源:PostCompileBehavior.php

示例6: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => 'date', BaseActiveRecord::EVENT_BEFORE_UPDATE => 'date', BaseActiveRecord::EVENT_AFTER_FIND => 'date'];
     }
 }
開發者ID:radiata-cms,項目名稱:radiata,代碼行數:10,代碼來源:DateTimeBehavior.php

示例7: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_DELETE => $this->trashAttribute];
     }
 }
開發者ID:sibds,項目名稱:yii2-trash-behavior,代碼行數:10,代碼來源:TrashBehavior.php

示例8: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->authorAttribute]];
     }
 }
開發者ID:nagser,項目名稱:users,代碼行數:10,代碼來源:AuthorBehavior.php

示例9: init

 public function init()
 {
     parent::init();
     if ($this->hashFunction == null) {
         $this->hashFunction = [$this, 'defaultHashFunction'];
     }
     $this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => $this->passwordAttribute, BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->passwordAttribute];
     $this->value = $this->hashFunction;
 }
開發者ID:krukru,項目名稱:yii2-extensions,代碼行數:9,代碼來源:HashablePasswordBehavior.php

示例10: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->attribute];
     }
     if ($this->attribute === null) {
         throw new InvalidConfigException('Either "attribute" or "value" property must be specified.');
     }
 }
開發者ID:emidia,項目名稱:yii2-jsonify,代碼行數:13,代碼來源:JsonifyBehavior.php

示例11: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [$this->trigger => $this->uniqueAttribute];
     }
     if (!empty($this->paramAttributes) && $this->paramOrder === null) {
         throw new InvalidConfigException('$paramOrder wajib diisi jika $paramAttributes diisi');
     }
     if ($this->length === null) {
         throw new InvalidConfigException('$length wajib diisi');
     }
 }
開發者ID:m-arfian,項目名稱:yii2-nyairombeng,代碼行數:16,代碼來源:UniqueCodeBehavior.php

示例12: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         $this->attributes = [BaseActiveRecord::EVENT_AFTER_INSERT => $this->imageAttributes, BaseActiveRecord::EVENT_AFTER_UPDATE => $this->imageAttributes];
         foreach ($this->imageAttributes as $attribute => $params) {
             if (is_numeric($attribute)) {
                 $attribute = $params;
                 $params = [];
             }
             $this->descriptors[$attribute] = Yii::createObject($params + ['class' => '\\vr\\image\\ImageAttributeDescriptor', 'attribute' => $attribute]);
         }
     }
 }
開發者ID:voodoo-mobile,項目名稱:yii2-image,代碼行數:17,代碼來源:ImageBehavior.php

示例13: init

 public function init()
 {
     parent::init();
     if (empty($this->attributes)) {
         foreach ($this->convertAttr as $key => $value) {
             $attrName = is_scalar($key) ? $key : $value;
             $convertType = is_scalar($key) ? $value : self::DEFAULT_CONVERT_TYPE;
             if (!in_array($convertType, $this->allowConvertType)) {
                 throw new \Exception(strtr('Disallow type convert "{type}"', ['{type}' => $convertType]));
             }
             $this->attributes[BaseActiveRecord::EVENT_BEFORE_INSERT][] = $attrName;
             $this->attributes[BaseActiveRecord::EVENT_BEFORE_UPDATE][] = $attrName;
             $this->attributes[BaseActiveRecord::EVENT_AFTER_FIND][] = $attrName;
             $this->attributes[BaseActiveRecord::EVENT_AFTER_INSERT][] = $attrName;
             $this->attributes[BaseActiveRecord::EVENT_AFTER_UPDATE][] = $attrName;
         }
     }
 }
開發者ID:wowkaster,項目名稱:yii2-serialize-attributes,代碼行數:18,代碼來源:SerializeAttributesBehavior.php

示例14: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->className == null) {
         throw new \yii\base\InvalidConfigException("'className' must be set");
     }
     if (!is_array($this->map)) {
         throw new \yii\base\InvalidConfigException("'map' must be an array; e.g.: ['gid' => 'group_id']");
     } else {
         if (!count($this->map) > 0) {
             throw new \yii\base\InvalidConfigException("'map' must contain the mapping group => local; e.g.: ['gid' => 'group_id']");
         }
     }
     if (!Yii::$app instanceof \yii\console\Application) {
         if (empty($this->attributes)) {
             $this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => array_values($this->map)[0]];
         }
     }
 }
開發者ID:e-frank,項目名稱:yii2-data,代碼行數:22,代碼來源:GroupBehavior.php

示例15: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->category = str_replace(['{', '%', '}'], '', $this->category);
 }
開發者ID:lajax,項目名稱:yii2-translate-manager,代碼行數:8,代碼來源:TranslateBehavior.php


注:本文中的yii\behaviors\AttributeBehavior::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。