当前位置: 首页>>代码示例>>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;未经允许,请勿转载。