bigdropinc / yii2-ajax-access-rule
yii2访问过滤器中的Ajax访问规则
1.0.0
2017-04-10 14:04 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-20 20:10:58 UTC
README
yii2访问过滤器中的Ajax访问规则
安装
安装此扩展的首选方式是通过Composer。
运行以下命令之一:
php composer.phar require --prefer-dist bigdropinc/yii2-ajax-access-rule "*"
或者将以下内容添加到你的composer.json
文件的require部分:
bigdropinc/yii2-ajax-access-rule
to the require section of your composer.json
file.
使用方法
对于访问控制规则,使用AjaxRule::className()
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'class' => AjaxRule::className(),
'actions' => ['some-action'],
'verbs' => ['POST'],
'allow' => true #this will allow only ajax requests for specified action
],
[
'class' => AjaxRule::className(),
'actions' => ['another-action'],
'allow' => false #this will allow only non-ajax request for specified action
],
]
]