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


PHP filters\Cors類代碼示例

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


在下文中一共展示了Cors類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['authenticator'] = ['class' => HttpBearerAuth::className(), 'except' => ['options']];
     $behaviors['corsFilter'] = ['class' => Cors::className()];
     return $behaviors;
 }
開發者ID:kuznetsov0209,項目名稱:mercdev-soccer-server,代碼行數:7,代碼來源:SecureActiveController.php

示例2: 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

示例3: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     // SEE https://github.com/yiisoft/yii2/pull/8626
     //$behaviors['corsFilter'] = [
     $behaviors[0] = ['class' => \yii\filters\Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'], 'Access-Control-Request-Headers' => ['*'], 'Access-Control-Allow-Credentials' => true, 'Access-Control-Expose-Headers' => ['Link', 'X-Pagination-Current-Page', 'X-Pagination-Page-Count', 'X-Pagination-Per-Page', 'X-Pagination-Total-Count']]];
     //$behaviors['authenticator'] = [
     $behaviors[1] = ['class' => \yii\filters\auth\HttpBearerAuth::className(), 'except' => ['options']];
     return $behaviors;
 }
開發者ID:shaan360,項目名稱:Yii2_foundation-apps,代碼行數:10,代碼來源:NestedActiveController.php

示例4: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $self = $this;
     return ['access' => ['class' => AccessControl::className(), 'only' => ['logout', 'signup'], 'rules' => [['actions' => ['signup'], 'allow' => true, 'roles' => ['?']], ['actions' => ['logout'], 'allow' => true, 'roles' => ['@']]], 'denyCallback' => function ($rule, $action) use($self) {
         if ('signup' == $action->id) {
             return $self->afterLogin();
         } else {
             return $self->redirect(['site/index']);
         }
     }], 'verbs' => ['class' => VerbFilter::className(), 'actions' => []], 'corsFilter' => ['class' => \yii\filters\Cors::className()]];
 }
開發者ID:shinzero999,項目名稱:Eveda-yii,代碼行數:14,代碼來源:SiteController.php

示例5: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     if ($this->jsonCallback) {
         $behaviors['contentNegotiator']['formats']['*/*'] = Response::FORMAT_JSONP;
         $behaviors['contentNegotiator']['formats']['application/xml'] = Response::FORMAT_JSONP;
         $behaviors['contentNegotiator']['formats']['application/json'] = Response::FORMAT_JSONP;
     } else {
         $behaviors['contentNegotiator']['formats']['*/*'] = Response::FORMAT_JSON;
         $behaviors['contentNegotiator']['formats']['application/xml'] = Response::FORMAT_JSON;
         $behaviors['contentNegotiator']['formats']['application/json'] = Response::FORMAT_JSON;
     }
     $behaviors['corsFilter'] = ['class' => yii\filters\Cors::className(), 'cors' => Yii::$app->params['cors']];
     return $behaviors;
 }
開發者ID:hustshenl,項目名稱:yii2-ucenter,代碼行數:15,代碼來源:RestController.php

示例6: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     //        $behaviors['corsFilter'] =
     //            [
     //                    'class' => Cors::className(),
     //                    'cors' => [
     //                        'Origin' => ['http://erp.local'],
     //                        'Origin' => ['*'],
     //                        'Access-Control-Request-Method' => ['GET', 'HEAD', 'OPTIONS'],
     //                    ],
     //            ];
     $behaviors['cors'] = ['class' => Cors::className()];
     return $behaviors;
 }
開發者ID:ninetor,項目名稱:newerp,代碼行數:15,代碼來源:UserController.php

示例7: behaviors

 /**
  * @internal
  * Only allows POST requests to the hook endpoints
  */
 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['index' => ['get'], 'view' => ['get']]], 'corsFilter' => ['class' => Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['GET', 'HEAD']]]];
 }
開發者ID:charlesportwoodii,項目名稱:galnet-api,代碼行數:8,代碼來源:CommoditiesController.php

示例8: behaviors

 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => 'jsonrpc']], 'authenticator' => ['class' => CompositeAuth::className(), 'optional' => ['index'], 'authMethods' => [UserAuth::className(), QueryParamAuth::className(), HttpBearerAuth::className()]], 'corsFilter' => ['class' => Cors::className()]]);
 }
開發者ID:voenniy,項目名稱:yii2-jsonrpc,代碼行數:4,代碼來源:FrontendController.php

示例9: behaviors

 public function behaviors()
 {
     return ['corsFilter' => ['class' => \yii\filters\Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['POST'], 'Access-Control-Request-Headers' => ['*']]]];
 }
開發者ID:sergey-exu,項目名稱:myhome,代碼行數:4,代碼來源:SiteController.php

示例10: behaviors

 /**
  * @var User User for check access.
  */
 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'corsFilter' => ['class' => \yii\filters\Cors::className()]];
 }
開發者ID:nguyentuansieu,項目名稱:yii2-mailbox,代碼行數:7,代碼來源:DefaultController.php

示例11: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML]], 'corsFilter' => ['class' => \yii\filters\Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'], 'Access-Control-Request-Headers' => ['Origin', 'X-Requested-With', 'Content-Type', 'Accept', 'Authorization'], 'Access-Control-Allow-Credentials' => true, 'Access-Control-Max-Age' => 86400, 'Access-Control-Expose-Headers' => []]], 'authenticator' => ['class' => HttpBearerAuth::className(), 'only' => ['dashboard']]];
 }
開發者ID:aheart,項目名稱:angularjs-yii2-part-2-authentication,代碼行數:7,代碼來源:ApiController.php

示例12: behaviors

 public function behaviors()
 {
     return \yii\helpers\ArrayHelper::merge(parent::behaviors(), [['class' => 'yii\\filters\\ContentNegotiator', 'formats' => ['application/json' => Response::FORMAT_JSON]], 'corsFilter' => ['class' => \yii\filters\Cors::className()]]);
 }
開發者ID:gorvic,項目名稱:part1.yii2,代碼行數:4,代碼來源:UserController.php

示例13: array_merge

<?php

$config = ['components' => ['assetManager' => ['class' => 'yii\\web\\AssetManager', 'linkAssets' => true, 'appendTimestamp' => YII_ENV_DEV]], 'as locale' => ['class' => 'common\\behaviors\\LocaleBehavior', 'enablePreferredLanguage' => true], 'as corsFilter' => ['class' => \yii\filters\Cors::className(), 'cors' => ['Origin' => array_merge(['https://fr.proxfree.com', 'http://fr.proxfree.com', 'http://proxfree.com', Yii::getAlias('@frontendUrl'), Yii::getAlias('@backendUrl')], explode(',', Yii::getAlias('@frontendUrls')))]]];
if (YII_DEBUG) {
    /* $config['bootstrap'][]      = 'debug';
       $config['modules']['debug'] = [
       'class'      => 'yii\debug\Module',
       'allowedIPs' => ['127.0.0.1', '::1', '192.168.33.1'],
       ]; */
}
if (YII_ENV_DEV) {
    $config['modules']['gii'] = ['allowedIPs' => ['127.0.0.1', '::1', '192.168.33.1']];
}
return $config;
開發者ID:allhaze,項目名稱:renault,代碼行數:14,代碼來源:web.php

示例14: behaviors

 public function behaviors()
 {
     return ['corsFilter' => ['class' => \yii\filters\Cors::className()]];
 }
開發者ID:2012lucho,項目名稱:TPB,代碼行數:4,代碼來源:BuscadorController.php

示例15: behaviors

 public function behaviors()
 {
     return ArrayHelper::merge([['class' => Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['GET'], 'Access-Control-Request-Headers' => ['*']]]], parent::behaviors());
 }
開發者ID:aekkapun,項目名稱:Yii2_foundation-apps,代碼行數:4,代碼來源:TagController.php


注:本文中的yii\filters\Cors類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。