bigdropinc/yii2-ajax-access-rule

Ajax access rule for yii2 access filter

1.0.0 2017-04-10 14:04 UTC

This package is not auto-updated.

Last update: 2024-11-15 20:47:22 UTC


README

Ajax access rule for yii2 access filter

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist bigdropinc/yii2-ajax-access-rule "*"

or add

bigdropinc/yii2-ajax-access-rule

to the require section of your composer.json file.

Usage

For AccessControl rules use 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
	                ],
	            ]
]