mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-17 23:09:10 +08:00
Added documentation to AccessControl.
This commit is contained in:
@@ -13,6 +13,39 @@ use yii\base\ActionFilter;
|
|||||||
use yii\base\HttpException;
|
use yii\base\HttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* AccessControl provides simple access control based on a set of rules.
|
||||||
|
*
|
||||||
|
* AccessControl is an action filter. It will check its [[rules]] to find
|
||||||
|
* the first rule that matches the current context variables (such as user IP address, user role).
|
||||||
|
* The matching rule will dictate whether to allow or deny the access to the requested controller
|
||||||
|
* action.
|
||||||
|
*
|
||||||
|
* To use AccessControl, declare it in the `behaviors()` method of your controller class.
|
||||||
|
* For example, the following declarations will allow authenticated users to access the "create"
|
||||||
|
* and "update" actions and deny all other users from accessing these two actions.
|
||||||
|
*
|
||||||
|
* ~~~
|
||||||
|
* public function behaviors()
|
||||||
|
* {
|
||||||
|
* return array(
|
||||||
|
* 'access' => array(
|
||||||
|
* 'class' => \yii\web\AccessControl::className(),
|
||||||
|
* 'only' => array('create', 'update'),
|
||||||
|
* 'rules' => array(
|
||||||
|
* // allow authenticated users
|
||||||
|
* array(
|
||||||
|
* 'allow' => true,
|
||||||
|
* 'roles' => array('@'),
|
||||||
|
* ),
|
||||||
|
* // deny all
|
||||||
|
* array(
|
||||||
|
* 'allow' => false,
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* ),
|
||||||
|
* );
|
||||||
|
* }
|
||||||
|
* ~~~
|
||||||
*
|
*
|
||||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user