當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。