本文整理匯總了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);
}