本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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()]]);
}
示例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;
}
示例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]]]);
}
示例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'],
],
],
];
*/
}
示例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']]]];
}
示例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;
}
示例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;
}
示例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;
}
示例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]]];
}
示例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]]]);
}