當前位置: 首頁>>代碼示例>>PHP>>正文


PHP filters\ContentNegotiator類代碼示例

本文整理匯總了PHP中yii\filters\ContentNegotiator的典型用法代碼示例。如果您正苦於以下問題:PHP ContentNegotiator類的具體用法?PHP ContentNegotiator怎麽用?PHP ContentNegotiator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ContentNegotiator類的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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。