本文整理汇总了PHP中yii\filters\Cors::className方法的典型用法代码示例。如果您正苦于以下问题:PHP Cors::className方法的具体用法?PHP Cors::className怎么用?PHP Cors::className使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\filters\Cors
的用法示例。
在下文中一共展示了Cors::className方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: behaviors
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = ['class' => HttpBearerAuth::className(), 'except' => ['options']];
$behaviors['corsFilter'] = ['class' => Cors::className()];
return $behaviors;
}
示例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;
}
示例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;
}
示例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()]];
}
示例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;
}
示例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;
}
示例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']]]];
}
示例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()]]);
}
示例9: behaviors
public function behaviors()
{
return ['corsFilter' => ['class' => \yii\filters\Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['POST'], 'Access-Control-Request-Headers' => ['*']]]];
}
示例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()]];
}
示例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']]];
}
示例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()]]);
}
示例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;
示例14: behaviors
public function behaviors()
{
return ['corsFilter' => ['class' => \yii\filters\Cors::className()]];
}
示例15: behaviors
public function behaviors()
{
return ArrayHelper::merge([['class' => Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['GET'], 'Access-Control-Request-Headers' => ['*']]]], parent::behaviors());
}