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.
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
Результат boolean whether the action should continue to be executed.
Пример #1
0
 /**
  * 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
 /**
  * @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
 /**
  * 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
 /**
  * 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);
 }