beforeAction() public method

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.
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
return boolean whether the action should continue to be executed.
コード例 #1
0
ファイル: AccessControl.php プロジェクト: apurey/cmf
 /**
  * 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);
 }
コード例 #2
0
ファイル: AccessControl.php プロジェクト: yii2mod/yii2-rbac
 /**
  * @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);
 }
コード例 #3
0
ファイル: AccessControl.php プロジェクト: reuhtte/yii2-admin
 /**
  * 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);
 }
コード例 #4
0
ファイル: AccessControl.php プロジェクト: babagay/razzd
 /**
  * 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);
 }