當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AccessControl::beforeAction方法代碼示例

本文整理匯總了PHP中yii\filters\AccessControl::beforeAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP AccessControl::beforeAction方法的具體用法?PHP AccessControl::beforeAction怎麽用?PHP AccessControl::beforeAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\filters\AccessControl的用法示例。


在下文中一共展示了AccessControl::beforeAction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * You may override this method to do last-minute preparation for the action.
  * @param \yii\base\Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     $user = Yii::$app->getUser();
     $uniqueId = $action->getUniqueId();
     if ($user->can($uniqueId)) {
         return true;
     }
     return parent::beforeAction($action);
 }
開發者ID:apurey,項目名稱:cmf,代碼行數:15,代碼來源:AccessControl.php

示例2: beforeAction

 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $controller = $action->controller;
     $params = ArrayHelper::getValue($this->params, $action->id, []);
     if (Yii::$app->user->can('/' . $action->getUniqueId(), $params)) {
         return true;
     }
     do {
         if (Yii::$app->user->can('/' . ltrim($controller->getUniqueId() . '/*', '/'))) {
             return true;
         }
         $controller = $controller->module;
     } while ($controller !== null);
     return parent::beforeAction($action);
 }
開發者ID:yii2mod,項目名稱:yii2-rbac,代碼行數:18,代碼來源:AccessControl.php

示例3: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * You may override this method to do last-minute preparation for the action.
  * @param InlineAction $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     $actionId = $action->getUniqueId();
     $user = Yii::$app->getUser();
     if ($user->can('/' . $actionId)) {
         return true;
     }
     $controller = $action->controller;
     do {
         if ($user->can('/' . ltrim($controller->getUniqueId() . '/*', '/'))) {
             return true;
         }
         $controller = $controller->module;
     } while ($controller !== null);
     return parent::beforeAction($action);
 }
開發者ID:reuhtte,項目名稱:yii2-admin,代碼行數:22,代碼來源:AccessControl.php

示例4: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * You may override this method to do last-minute preparation for the action.
  * @param Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     return parent::beforeAction($action);
 }
開發者ID:babagay,項目名稱:razzd,代碼行數:10,代碼來源:AccessControl.php


注:本文中的yii\filters\AccessControl::beforeAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。