mg-code / yii2-filters
A collection of useful filters for Yii framework 2.0
Installs: 4 791
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-10-27 03:52:20 UTC
README
This filter throws an exception (BadRequestHttpException) if the applied action is receiving a non-AJAX request.
Usage
To use AjaxFilter, declare it in the behaviors()
method of your controller class.
Use only
and except
properties to include/exclude actions from filter.
public function behaviors() { return [ 'onlyAjax' => [ 'class' => \mgcode\filters\AjaxFilter::className(), 'only' => ['ajaxValidate'], ], ]; }
DisableCsrfValidationFilter
This filter disables csrf validation. Mostly used for feedback actions (e.g. when receiving response from payment service).
Usage
To use DisableCsrfValidationFilter, declare it in the behaviors()
method of your controller class.
Use only
and except
properties to include/exclude actions from filter.
public function behaviors() { return [ 'disableCsrf' => [ 'class' => \mgcode\filters\DisableCsrfValidationFilter::className(), 'only' => ['feedback'], ], ]; }