本文整理汇总了PHP中yii\web\Controller::behaviors方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::behaviors方法的具体用法?PHP Controller::behaviors怎么用?PHP Controller::behaviors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Controller
的用法示例。
在下文中一共展示了Controller::behaviors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: behaviors
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['accessControl'] = $this->accessControlBehavior();
$behaviors['accessControl']['rules'] = array_merge([['allow' => true, 'actions' => ['grid-view-settings', 'route-to-url'], 'roles' => ['@']]], $behaviors['accessControl']['rules']);
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
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_HTML;
// $behaviors['contentNegotiator']['languages'] = [ 'en', 'zh-CN',];
return $behaviors;
}
示例4: behaviors
public function behaviors()
{
$behaviors = parent::behaviors();
// TODO: Change the autogenerated stub
$behaviors['authenticator'] = ['class' => QueryParamAuth::className(), 'tokenParam' => 'passkey'];
return $behaviors;
}
示例5: behaviors
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = ['class' => HttpBearerAuth::className()];
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
return $behaviors;
}
示例6: behaviors
public function behaviors()
{
$behaviors = parent::behaviors();
// TODO: Change the autogenerated stub
$behaviors['authenticator'] = ['class' => QueryParamAuth::className(), 'tokenParam' => 'passkey'];
$behaviors[] = ['class' => 'yii\\filters\\ContentNegotiator', 'formats' => ['application/json' => Response::FORMAT_JSON, 'text/html' => Response::FORMAT_HTML]];
return $behaviors;
}
示例7: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['access']['rules'] = [['allow' => true, 'actions' => ['index'], 'roles' => ['BViewRules']]];
$behaviors['access']['rules'][] = ['allow' => true, 'actions' => ['create'], 'roles' => ['BCreateRules']];
$behaviors['access']['rules'][] = ['allow' => true, 'actions' => ['delete', 'batch-delete'], 'roles' => ['BDeleteRules']];
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['index' => ['get'], 'create' => ['get', 'post'], 'delete' => ['post', 'delete'], 'batch-delete' => ['post', 'delete']]];
return $behaviors;
}
示例8: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
if (!isset($behaviors['access']['class'])) {
$behaviors['access']['class'] = AccessControl::className();
}
$behaviors['access']['rules'][] = ['allow' => true, 'actions' => ['index', 'view'], 'roles' => ['viewBlogs']];
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['index' => ['get'], 'view' => ['get']]];
return $behaviors;
}
示例9: behaviors
public function behaviors()
{
if (is_array($this->_behaviorsData)) {
return $this->_behaviorsData;
}
if (is_callable($this->_behaviorsData)) {
return call_user_func($this->_behaviorsData, $this);
}
return parent::behaviors();
}
示例10: behaviors
public function behaviors()
{
$rules = [['allow' => true, 'roles' => ['@']]];
return \yii\helpers\ArrayHelper::merge(parent::behaviors(), ['access' => ['class' => AccessControl::className(), 'rules' => $rules, 'denyCallback' => function ($rule, $action) {
if (Yii::$app->getUser()->isGuest) {
Yii::$app->getSession()->addFlash('warning', Yii::t('app', 'La sessione è scaduta, effettua il login'));
Yii::$app->getUser()->loginRequired();
}
throw new ForbiddenHttpException(Yii::t('app', 'Non sei autorizzato a visualizzare questa pagina'));
}], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]]);
}
示例11: behaviors
/**
* Returns a list of behaviors that this component should behave as.
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$rulesIps = [];
if (false === empty(\Yii::$app->params['secret']['allowIPs'])) {
$rulesIps = \Yii::$app->params['secret']['allowIPs'];
}
$behaviors['AccessControl'] = ['class' => 'yii\\filters\\AccessControl', 'denyCallback' => function ($rule, $action) {
throw new ForbiddenHttpException(\Yii::t('yii', 'You are not allowed to perform this action.'));
}, 'rules' => [['allow' => true, 'ips' => $rulesIps]]];
return $behaviors;
}
示例12: behaviors
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['file-cache' => ['class' => HttpCache::class, 'only' => ['view', 'get'], 'lastModified' => function () {
$id = Yii::$app->request->get('id');
$nocache = Yii::$app->request->get('nocache', false);
if ($nocache) {
return time();
}
$filename = Yii::$app->fileStorage->get($id);
return filemtime($filename);
}]]);
}
示例13: 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'],
],
],
];
*/
}
示例14: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['create' => ['post'], 'update' => ['put', 'post'], 'delete' => ['post', 'delete']]];
return $behaviors;
}
示例15: behaviors
/**
* {@inheritdoc}
*/
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'only' => ['resource'], 'formats' => ['application/json' => Response::FORMAT_JSON]]]);
}