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


PHP ActiveRecord::behaviors方法代碼示例

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


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

示例1: behaviors

 public function behaviors()
 {
     $behaviors = ['attributesMapBehavior' => ['class' => '\\yiicod\\mailqueue\\models\\behaviors\\AttributesMapBehavior', 'attributesMap' => Yii::$app->get('mailqueue')->modelMap['MailQueue']], 'timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => in_array(Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldCreateDate'], $this->attributes()) ? Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldCreateDate'] : null, 'updatedAtAttribute' => in_array(Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldUpdateDate'], $this->attributes()) ? Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldUpdateDate'] : null, 'value' => function () {
         return date("Y-m-d H:i:s");
     }], 'XssBehavior' => ['class' => '\\yiicod\\base\\models\\behaviors\\XssBehavior', 'attributesExclude' => array(Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldBody'])]];
     return ArrayHelper::merge(parent::behaviors(), $behaviors);
 }
開發者ID:yiicod,項目名稱:yii2-mailqueue,代碼行數:7,代碼來源:MailQueueModel.php

示例2: behaviors

 public function behaviors()
 {
     $result = parent::behaviors();
     return array_merge($result, ['timestamp' => ['class' => \yii\behaviors\TimestampBehavior::className(), 'attributes' => [\yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => 'date_update'], 'value' => function () {
         return date('Y-m-d H:i:s');
     }]]);
 }
開發者ID:evgenylev,項目名稱:books,代碼行數:7,代碼來源:Books.php

示例3: behaviors

 /**
  * @return array Behaviors
  */
 public function behaviors()
 {
     $items = parent::behaviors();
     if ($this->timeStampBehaviorEnabled && $this->hasAttribute('created_at')) {
         $items['date'] = ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => $this->hasAttribute('updated_at') ? 'updated_at' : 'created_at', 'value' => function () {
             return date('Y-m-d H:i:s');
         }];
     }
     return $items;
 }
開發者ID:platx,項目名稱:yii2-active-record,代碼行數:13,代碼來源:ActiveRecord.php

示例4: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return array_merge(parent::behaviors(), [BlameableBehavior::className() => ['class' => BlameableBehavior::className(), 'value' => function ($event) {
         if (\Yii::$app instanceof \yii\console\Application) {
             return null;
         } else {
             $user = Yii::$app->get('user', false);
             return $user && !$user->isGuest ? $user->id : null;
         }
     }], TimestampBehavior::className() => ['class' => TimestampBehavior::className()], HasTableCache::className() => ['class' => HasTableCache::className(), 'cache' => \Yii::$app->cache]]);
 }
開發者ID:skeeks-cms,項目名稱:cms,代碼行數:14,代碼來源:Core.php

示例5: behaviors

 /**
  * (array) behaviors :
  * @return array
  */
 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['timestamp' => ['class' => TimestampBehavior::className()], 'audit' => ['class' => AuditTrailBehavior::className()]]);
 }
開發者ID:tqsq2005,項目名稱:Yii2adv,代碼行數:8,代碼來源:Events.php

示例6: behaviors

 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['timestamp' => ['class' => 'yii\\behaviors\\TimestampBehavior', 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']]], 'slug' => ['class' => 'yii\\behaviors\\SluggableBehavior', 'attribute' => 'title', 'slugAttribute' => 'slug', 'immutable' => true, 'ensureUnique' => true]]);
 }
開發者ID:giicms,項目名稱:tour,代碼行數:4,代碼來源:Post.php

示例7: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['timestamp' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdAt', 'updatedAtAttribute' => 'updatedAt']]);
 }
開發者ID:understeam,項目名稱:yii2-command-scheduler,代碼行數:7,代碼來源:DbTask.php

示例8: behaviors

 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['timestamp' => ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'], 'value' => function () {
         return time();
     }]]);
 }
開發者ID:infoweb-internet-solutions,項目名稱:yii2-cms-pages,代碼行數:6,代碼來源:PageTemplate.php

示例9: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return array_merge(parent::behaviors(), [['class' => CascadeBehavior::className(), 'children' => ['files']]]);
 }
開發者ID:vastander,項目名稱:yii2-eer,代碼行數:7,代碼來源:StudentResult.php

示例10: behaviors

 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['slug' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'slugAttribute' => 'slug', 'immutable' => true, 'ensureUnique' => true]]);
 }
開發者ID:huynhtuvinh87,項目名稱:cms,代碼行數:4,代碼來源:Category.php

示例11: behaviors

 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), [Relations::className(), ['class' => TimestampBehavior::className()]]);
 }
開發者ID:vtvz,項目名稱:yii2-basics,代碼行數:4,代碼來源:BaseUser.php

示例12: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors[] = TimestampBehavior::className();
     return $behaviors;
 }
開發者ID:VitProg,項目名稱:yii2rest_test,代碼行數:9,代碼來源:User.php

示例13: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors[] = ['class' => AttachBehavior::className(), 'models' => ['avatar' => ['class' => UserAvatarFile::className()]]];
     return $behaviors;
 }
開發者ID:artkost,項目名稱:yii2-starter-kit,代碼行數:9,代碼來源:UserProfile.php

示例14: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return array_merge(parent::behaviors(), [['class' => CascadeBehavior::className(), 'children' => ['disciplineNames', 'studentEducations', 'files']]]);
 }
開發者ID:vkabachenko,項目名稱:yii2-eer,代碼行數:7,代碼來源:Program.php

示例15: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return array_merge(parent::behaviors(), [FileBehavior::className()]);
 }
開發者ID:vastander,項目名稱:yii2-eer,代碼行數:7,代碼來源:File.php


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