bigdropinc/yii2-ajax-access-rule

yii2访问过滤器中的Ajax访问规则

安装: 231

依赖项: 0

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 1

公开问题: 0

类型:yii2-extension

1.0.0 2017-04-10 14:04 UTC

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
	                ],
	            ]
]