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 | the action to be executed. | |
return | boolean | whether the action should continue to be executed. |
/** * 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); }
/** * @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); }
/** * 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); }
/** * 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); }