Commit 133edb23 by Qiang Xue

Added documentation to AccessControl.

parent 210faf78
...@@ -13,6 +13,39 @@ use yii\base\ActionFilter; ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment