yii2-ajax-access-rule
Ajax access rule for yii2 access filter, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist bigdropinc/yii2-ajax-access-rule "*"
or add, (*4)
bigdropinc/yii2-ajax-access-rule
to the require section of your composer.json
file., (*5)
Usage
For AccessControl rules use AjaxRule::className(), (*6)
'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
],
]
]