本文整理汇总了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);
}
示例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');
}]]);
}
示例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;
}
示例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]]);
}
示例5: behaviors
/**
* (array) behaviors :
* @return array
*/
public function behaviors()
{
return array_merge(parent::behaviors(), ['timestamp' => ['class' => TimestampBehavior::className()], 'audit' => ['class' => AuditTrailBehavior::className()]]);
}
示例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]]);
}
示例7: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['timestamp' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdAt', 'updatedAtAttribute' => 'updatedAt']]);
}
示例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();
}]]);
}
示例9: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), [['class' => CascadeBehavior::className(), 'children' => ['files']]]);
}
示例10: behaviors
public function behaviors()
{
return array_merge(parent::behaviors(), ['slug' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'slugAttribute' => 'slug', 'immutable' => true, 'ensureUnique' => true]]);
}
示例11: behaviors
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), [Relations::className(), ['class' => TimestampBehavior::className()]]);
}
示例12: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors[] = TimestampBehavior::className();
return $behaviors;
}
示例13: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors[] = ['class' => AttachBehavior::className(), 'models' => ['avatar' => ['class' => UserAvatarFile::className()]]];
return $behaviors;
}
示例14: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), [['class' => CascadeBehavior::className(), 'children' => ['disciplineNames', 'studentEducations', 'files']]]);
}
示例15: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), [FileBehavior::className()]);
}