本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}