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


PHP ContentNegotiator::className方法代码示例

本文整理汇总了PHP中yii\filters\ContentNegotiator::className方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentNegotiator::className方法的具体用法?PHP ContentNegotiator::className怎么用?PHP ContentNegotiator::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\filters\ContentNegotiator的用法示例。


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

示例1: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application\\json' => Response::FORMAT_JSON]];
     $behaviors['authenticator'] = ['class' => QueryParamAuth::className()];
     return $behaviors;
 }
开发者ID:dshashkov,项目名称:YiiTask1,代码行数:7,代码来源:TweetController.php

示例2: behaviors

 /**
  * {@inheritDoc}
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
     $behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['*' => ['GET', 'AJAX'], 'file-upload' => ['POST', 'AJAX']]];
     return $behaviors;
 }
开发者ID:navatech,项目名称:yii2-roxymce,代码行数:10,代码来源:ManagementController.php

示例3: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['rateLimiter'] = ['class' => RateLimiter::className(), 'enableRateLimitHeaders' => false];
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
     return $behaviors;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:10,代码来源:UserController.php

示例4: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['authenticator'] = ['class' => HttpBearerAuth::className(), 'only' => ['dashboard']];
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
     $behaviors['access'] = ['class' => AccessControl::className(), 'only' => ['dashboard'], 'rules' => [['actions' => ['dashboard'], 'allow' => true, 'roles' => ['@']]]];
     return $behaviors;
 }
开发者ID:engrashid,项目名称:library,代码行数:11,代码来源:ApiController.php

示例5: behaviors

 public function behaviors()
 {
     // Options Request Behavior must going at first because swagger makes OPTIONS requests before POST
     // and this behavior must run early than VerbsFilter
     $behaviors = ['optionsRequestFilter' => OptionsRequestFilter::className()];
     $behaviors = array_merge($behaviors, parent::behaviors(), ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]], 'corsFilter' => Cors::className(), 'authenticator' => QueryParamAuthSwagger::className()]);
     return $behaviors;
 }
开发者ID:VictorGub,项目名称:yii2-swagger,代码行数:8,代码来源:Controller.php

示例6: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     // bootstrap the ContentNegotiatot behavior earlier to use detected format for authenticator
     /** @var ContentNegotiator $contentNegotiator */
     $contentNegotiator = Yii::createObject(['class' => ContentNegotiator::className(), 'formats' => ['text/html' => Response::FORMAT_HTML, 'application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML, 'text/csv' => Response::FORMAT_CSV, 'application/pdf' => Response::FORMAT_PDF, 'application/vnd.ms-excel' => Response::FORMAT_XLS]]);
     $contentNegotiator->negotiate();
     return array_merge(parent::behaviors(), ['contentNegotiator' => $contentNegotiator, 'authenticator' => ['class' => \yii\filters\auth\CompositeAuth::className(), 'authMethods' => !Yii::$app->user->getIsGuest() || Yii::$app->response->format === Response::FORMAT_HTML ? [] : [\yii\filters\auth\HttpBasicAuth::className(), \yii\filters\auth\QueryParamAuth::className()]], 'rateLimiter' => ['class' => \yii\filters\RateLimiter::className(), 'user' => Yii::$app->user->getIdentity()], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@']]]], 'menu' => ['class' => ActiveNavigation::className()]]);
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:11,代码来源:ActiveController.php

示例7: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['authenticator'] = ['class' => HttpBasicAuth::className(), 'auth' => [$this, 'auth'], 'only' => ['create', 'update', 'delete']];
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML]];
     $behaviors['access'] = ['class' => AccessControl::className(), 'ruleConfig' => ['class' => AccessRule::className()], 'only' => ['create', 'update', 'delete'], 'rules' => [['allow' => true, 'actions' => ['create', 'update'], 'roles' => [User::ROLE_ADMIN, User::ROLE_USER]], ['allow' => true, 'actions' => ['delete'], 'roles' => [User::ROLE_ADMIN]]]];
     $behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['search-airport' => ['post', 'get']]];
     return $behaviors;
 }
开发者ID:shii,项目名称:yii-app,代码行数:9,代码来源:AirportController.php

示例8: behaviors

 public function behaviors()
 {
     $public_actions = isset(Yii::$app->params["public-actions"]) ? Yii::$app->params["public-actions"] : [];
     $behaviors = parent::behaviors();
     if (isset($public_actions[$this->className()])) {
         $this->public_actions = array_merge($this->public_actions, $public_actions[$this->className()]);
     }
     $behaviors['OAuth'] = ['class' => OAuthBearerFilter::className(), 'except' => $this->public_actions];
     return array_merge($behaviors, ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]]]);
 }
开发者ID:rowasc,项目名称:yii2oauthserver,代码行数:10,代码来源:ApiController.php

示例9: behaviors

 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['login', 'error'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'bootstrap' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'charset' => 'UTF-8'], 'languages' => ['en', 'de']]]);
     /*
     return [
                 'verbs' => [
                     'class' => VerbFilter::className(),
                     'actions' => [
                         'delete' => ['post'],
                     ],
                 ],
             ];
     */
 }
开发者ID:adem-team,项目名称:advanced,代码行数:14,代码来源:RptEsmController.php

示例10: behaviors

 public function behaviors()
 {
     return ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['text/html' => Response::FORMAT_JSON]], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'actions' => ['get', 'widget-get'], 'matchCallback' => function ($rule, $action) {
         $this->checkCsrfToken();
         $this->checkIdentity();
         $this->checkUserRelation(Yii::$app->request->post('id'));
         return true;
     }], ['allow' => true, 'actions' => ['list', 'widget-list', 'page-count'], 'matchCallback' => function ($rule, $action) {
         $this->checkCsrfToken();
         $this->checkIdentity();
         return true;
     }]], 'denyCallback' => function ($rule, $action) {
         throw new ForbiddenHttpException('Access Denied.');
     }], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['get' => ['post'], 'widget-get' => ['post'], 'list' => ['post'], 'widget-list' => ['post'], 'page-count' => ['post']]]];
 }
开发者ID:rhosocial,项目名称:rho.social,代码行数:15,代码来源:ContactController.php

示例11: behaviors

 public function behaviors()
 {
     // get the parent behaviors to overwrite
     $behaviors = parent::behaviors();
     if (!$this->getUserAuthClass()) {
         unset($behaviors['authenticator']);
         unset($behaviors['rateLimiter']);
     } else {
         // change to admin user auth class
         $behaviors['authenticator'] = ['class' => \yii\filters\auth\CompositeAuth::className(), 'user' => $this->getUserAuthClass(), 'authMethods' => [\yii\filters\auth\QueryParamAuth::className(), \yii\filters\auth\HttpBearerAuth::className()]];
         // change to admin rate limiter
         $behaviors['rateLimiter'] = ['class' => \yii\filters\RateLimiter::className(), 'user' => $this->getUserAuthClass()];
     }
     $behaviors['contentNegotiator'] = ['class' => \yii\filters\ContentNegotiator::className(), 'formats' => ['application/json' => \yii\web\Response::FORMAT_JSON, 'application/xml' => \yii\web\Response::FORMAT_XML]];
     return $behaviors;
 }
开发者ID:gitter-badger,项目名称:luya,代码行数:16,代码来源:BehaviorTrait.php

示例12: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     //set response header to application/json only
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
     $behaviors['ipFilter'] = ['class' => IPFilter::className()];
     $behaviors['tokenFilter'] = ['class' => TokenFilter::className()];
     $behaviors['openPollFilter'] = ['class' => OpenPollFilter::className()];
     // $behaviors['verbs'] = [
     //     'class' => VerbFilter::className(),
     //     'actions' => [
     //         'submit' => ['get'],
     //         'get' => ['get'],
     //     ],
     // ];
     return $behaviors;
 }
开发者ID:EuresTools,项目名称:eVote-web,代码行数:17,代码来源:VotingRestController.php

示例13: behaviors

 /**
  * Remove not used behaviors from parent behaviors.
  *
  * @return array The list of behvaiors.
  */
 public function behaviors()
 {
     // get the parent behaviors to overwrite
     $behaviors = parent::behaviors();
     if (!$this->getUserAuthClass()) {
         unset($behaviors['authenticator']);
     } else {
         // change to admin user auth class
         $behaviors['authenticator'] = ['class' => CompositeAuth::className(), 'user' => $this->getUserAuthClass(), 'authMethods' => [QueryParamAuth::className(), HttpBearerAuth::className()]];
     }
     $behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML]];
     // by default rate limiter behavior is removed as its not implememented.
     if (isset($behaviors['rateLimiter'])) {
         unset($behaviors['rateLimiter']);
     }
     return $behaviors;
 }
开发者ID:luyadev,项目名称:luya-core,代码行数:22,代码来源:RestBehaviorsTrait.php

示例14: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['verb' => ['class' => 'yii\\filters\\VerbFilter', 'actions' => ['delete' => ['post']]], 'access' => ['class' => 'yii\\filters\\AccessControl', 'only' => ['upload', 'delete'], 'rules' => [['allow' => true, 'roles' => ['@']]]], 'negotiator' => ['class' => ContentNegotiator::className(), 'only' => ['upload', 'delete'], 'formats' => ['application/json' => Response::FORMAT_JSON]]];
 }
开发者ID:cyhalothrin,项目名称:yiiflow,代码行数:7,代码来源:FlowController.php

示例15: behaviors

 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['authenticator' => ['class' => CompositeAuth::className(), 'authMethods' => [['class' => HttpBearerAuth::className()], ['class' => QueryParamAuth::className(), 'tokenParam' => 'access-token']]], 'bootstrap' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]]]);
 }
开发者ID:C12D,项目名称:api,代码行数:4,代码来源:BarangumumController.php


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