From 133edb2352ce88f9f10b5568ceff8470dede05b6 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 23 May 2013 21:01:01 -0400 Subject: [PATCH] Added documentation to AccessControl. --- framework/yii/web/AccessControl.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/framework/yii/web/AccessControl.php b/framework/yii/web/AccessControl.php index c4efd19..ce64533 100644 --- a/framework/yii/web/AccessControl.php +++ b/framework/yii/web/AccessControl.php @@ -13,6 +13,39 @@ use yii\base\ActionFilter; 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 * @since 2.0