当前位置: 首页>>代码示例>>PHP>>正文


PHP behaviors\BlameableBehavior类代码示例

本文整理汇总了PHP中yii\behaviors\BlameableBehavior的典型用法代码示例。如果您正苦于以下问题:PHP BlameableBehavior类的具体用法?PHP BlameableBehavior怎么用?PHP BlameableBehavior使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BlameableBehavior类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: behaviors

 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'value' => function ($event) {
         $user = Yii::$app->get('user', false);
         return $user && !$user->isGuest ? $user->identity->username : null;
     }]];
 }
开发者ID:joorloohuis,项目名称:bat-web-frontend,代码行数:7,代码来源:Upload.php

示例2: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at']]], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'created_ip'], 'value' => function ($event) {
         return ip2long(Yii::$app->request->getUserIP());
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'created_ip'], 'value' => function ($event) {
         return long2ip($event->sender->created_ip);
     }], ['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'user_id']]];
 }
开发者ID:faninv,项目名称:gtqa,代码行数:11,代码来源:Favorite.php

示例3: behaviors

 public function behaviors()
 {
     return [['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['route']], 'value' => function ($event) {
         return Yii::$app->requestedRoute;
     }], ['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_id']]], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['ip']], 'value' => function ($event) {
         return Yii::$app->getRequest()->getUserIP();
     }], ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['datetime']]]];
 }
开发者ID:pythagor,项目名称:yii2-mongolog,代码行数:8,代码来源:Log.php

示例4: behaviors

 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at'], ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'user_id', 'updatedByAttribute' => 'user_id'], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'theMust'], 'value' => function ($event) {
         return $this->kpi->the_must;
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'theBest'], 'value' => function ($event) {
         return $this->kpi->the_best;
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'groupName'], 'value' => function ($event) {
         return $this->kpi->group->name;
     }]];
 }
开发者ID:phisithos,项目名称:yii2-workshop-co-sapce,代码行数:10,代码来源:EvauateScore.php

示例5: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'alias'], 'value' => function ($event) {
         return Inflector::slug($event->sender->title);
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm'));
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_VALIDATE => 'tags'], 'value' => function ($event) {
         return $event->sender->tags ? strip_tags($event->sender->tags) : $event->sender->tags;
     }], ['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'user_id']]];
 }
开发者ID:dextercool,项目名称:yii2-qa,代码行数:13,代码来源:Question.php

示例6: retrieveModel

 /**
  * 
  * @param type $id
  * @param type $allowReturnNew
  * @return \cza\base\components\controllers\backend\modelClass
  * @throws NotFoundHttpException
  */
 public function retrieveModel($id = null, $allowReturnNew = true)
 {
     $model = parent::retrieveModel($id, $allowReturnNew);
     $model->attachBehavior('BlameableBehavior', ['class' => BlameableBehavior::className()]);
     $cmsFields = $this->getCmsFields();
     if (!empty($cmsFields)) {
         $model->attachBehavior('CmsMediaBehavior', ['class' => CmsMediaBehavior::className(), 'fields' => $cmsFields]);
     }
     return $model;
 }
开发者ID:bennybi,项目名称:yii2-cza-base,代码行数:17,代码来源:CmsController.php

示例7: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_id']]], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_ip']], 'value' => function ($event) {
         return Yii::$app->getRequest()->getUserIP();
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_host']], 'value' => function ($event) {
         return Yii::$app->getRequest()->getUserHost();
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_agent']], 'value' => function ($event) {
         return Yii::$app->getRequest()->getUserAgent();
     }]];
 }
开发者ID:statsandresults,项目名称:statsandresults,代码行数:13,代码来源:Contact.php

示例8: 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:Liv1020,项目名称:cms,代码行数:14,代码来源:Core.php

示例9: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['dt' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_date', 'updatedAtAttribute' => 'updated_date', 'value' => new Expression('NOW()')], 'us' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_user', 'updatedByAttribute' => 'updated_user'], 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'posts', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/images/posts/gallery', 'url' => Yii::getAlias('@web') . '/images/posts/gallery', 'versions' => ['small' => function ($img) {
         /** @var \Imagine\Image\ImageInterface $img */
         return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200));
     }, 'medium' => function ($img) {
         /** @var Imagine\Image\ImageInterface $img */
         $dstSize = $img->getSize();
         $maxWidth = 800;
         if ($dstSize->getWidth() > $maxWidth) {
             $dstSize = $dstSize->widen($maxWidth);
         }
         return $img->copy()->resize($dstSize);
     }]]];
 }
开发者ID:serker72,项目名称:cross-stitch,代码行数:18,代码来源:KskPosts.php

示例10: behaviors

 public function behaviors()
 {
     $behaviors = ['sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true, "immutable" => true]];
     $behaviors['author_id'] = ['class' => BlameableBehavior::className(), 'attributes' => [static::EVENT_BEFORE_INSERT => 'author_id']];
     $behaviors['timestamp'] = TimestampBehavior::className();
     $behaviors['published_at'] = ['class' => StrToTimeBehavior::className(), 'attribute' => 'published_at'];
     $behaviors['taggabble'] = Taggable::className();
     $behaviors['meta'] = MetaBehavior::className();
     $behaviors['thumbnailFile'] = ['class' => \hass\attachment\behaviors\UploadBehavior::className(), 'attribute' => 'thumbnail'];
     $behaviors['taxonomy'] = ['class' => TaxonomyBehavior::className()];
     $behaviors['textEditor'] = ['class' => \hass\base\misc\editor\EditorBehavior::className(), 'attribute' => 'content'];
     $behaviors['TimestampFormatter'] = TimestampFormatter::className();
     $behaviors['commentEnabled'] = ['class' => CommentBehavior::className(), 'defaultStatus' => CommentEnabledEnum::STATUS_ON];
     return $behaviors;
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:15,代码来源:Post.php

示例11: checkAdvancedAccess

 public function checkAdvancedAccess()
 {
     if (Validate::validate(new HasBehavior(BlameableBehavior::className()), $this->controller->model)->isValid()) {
         //Если такая привилегия заведена, нужно ее проверять.
         if ($permission = \Yii::$app->authManager->getPermission(CmsManager::PERMISSION_ALLOW_MODEL_UPDATE_ADVANCED)) {
             if (!\Yii::$app->user->can($permission->name, ['model' => $this->controller->model])) {
                 return false;
             }
         }
     } else {
         //Если такая привилегия заведена, нужно ее проверять.
         if ($permission = \Yii::$app->authManager->getPermission(CmsManager::PERMISSION_ALLOW_MODEL_UPDATE_ADVANCED)) {
             if (!\Yii::$app->user->can($permission->name)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:Liv1020,项目名称:cms,代码行数:19,代码来源:AdminOneModelSystemAction.php

示例12: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     list($route, $params) = Yii::$app->getRequest()->resolve();
     $isWebApp = Yii::$app instanceof \yii\web\Application;
     $webAppBehaviors = [];
     $commonBehaviors = [['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['app_id']], 'value' => function ($event) {
         return Yii::$app->id;
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['route']], 'value' => function ($event) use($route) {
         return $route;
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['params']], 'value' => function ($event) use($params) {
         array_walk_recursive($params, function (&$value) {
             $value = utf8_encode($value);
         });
         return var_export($params, true);
     }], ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['datetime']], 'value' => new Expression('now()')]];
     if ($isWebApp) {
         $webAppBehaviors = [['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_id']]], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['ip']], 'value' => function ($event) {
             return Yii::$app->getRequest()->getUserIP();
         }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['user_agent']], 'value' => function ($event) {
             return Yii::$app->getRequest()->getUserAgent();
         }]];
     }
     return ArrayHelper::merge($commonBehaviors, $webAppBehaviors);
 }
开发者ID:zelenin,项目名称:yii2-request-log-module,代码行数:27,代码来源:RequestLog.php

示例13: behaviors

 public function behaviors()
 {
     return ['timestamp' => ['class' => 'yii\\behaviors\\TimestampBehavior', 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']], 'value' => new Expression('NOW()')], 'blameable' => ['class' => \yii\behaviors\BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by'], ['class' => SluggableBehavior::className(), 'attribute' => 'titulo', 'slugAttribute' => 'seo_slug']];
 }
开发者ID:nando9,项目名称:yii2capa8,代码行数:4,代码来源:Noticia.php

示例14: behaviors

 public function behaviors()
 {
     return [TimestampBehavior::className(), BlameableBehavior::className()];
 }
开发者ID:poykub,项目名称:wph,代码行数:4,代码来源:Comstock.php

示例15: behaviors

 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'attributes' => [\yii\db\ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], \yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']], 'value' => new Expression('NOW()')], 'blameable' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by']];
 }
开发者ID:hsleonis,项目名称:basetech,代码行数:4,代码来源:ProductCategory.php


注:本文中的yii\behaviors\BlameableBehavior类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。