本文整理匯總了PHP中yii\filters\AccessControl::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP AccessControl::init方法的具體用法?PHP AccessControl::init怎麽用?PHP AccessControl::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\filters\AccessControl
的用法示例。
在下文中一共展示了AccessControl::init方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
/**
* @inheritdoc
*/
public function init()
{
if ($this->entity) {
$this->rules = array_merge($this->entity);
}
parent::init();
}
示例2: init
public function init()
{
$rule = ['allow' => true, 'matchCallback' => function ($rule, $action) {
return RoleManager::checkAccess($action);
}];
$this->rules[] = \Yii::createObject(array_merge($this->ruleConfig, $rule));
parent::init();
}
示例3: init
/**
* @see \yii\filters\AccessControl::init()
*/
public function init()
{
parent::init();
//非正式環境下,每次請求都要對當前頁麵的權限進行檢查
if (!YII_ENV_PROD) {
$this->checkAuthItem();
}
}
示例4: init
/**
* Initializes the [[rules]] array by instantiating rule objects from configurations.
*/
public function init()
{
parent::init();
$this->user = Instance::ensure($this->user, User::className());
foreach ($this->rules as $i => $rule) {
if (is_array($rule)) {
$this->rules[$i] = Yii::createObject(array_merge($this->ruleConfig, $rule));
}
}
}
示例5: init
public function init()
{
parent::init();
if ($this->user->isGuest) {
return true;
}
if (!$this->Privilege()) {
die('您沒有權限訪問這個頁麵!');
}
}
示例6: init
public function init()
{
$this->user = Instance::ensure($this->user, User::className());
$rolesObject = Yii::$app->authManager->getRolesByUser($this->user->id);
if (!empty($rolesObject)) {
foreach ($rolesObject as $roles => $object) {
foreach ($object->data as $route) {
$this->_actions[] = $route;
}
}
}
$this->rules = [['actions' => $this->_actions, 'allow' => true]];
parent::init();
}
示例7: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!$this->denyMessage && !Yii::$app->user->isGuest) {
$this->denyMessage = Yii::t('user', 'You have no rights to perform this action');
} else {
if (!$this->denyMessage && Yii::$app->user->isGuest) {
$this->denyMessage = Yii::t('user', 'Need authorization to perform this action');
}
}
$this->denyCallback = function ($rule, $action) {
if ($this->denyMessage) {
/* @var $systemAlert Alert */
$systemAlert = Yii::$app->systemAlert;
$systemAlert->setMessage(Alert::DANGER, $this->denyMessage);
}
if (Yii::$app->user->isGuest) {
Yii::$app->user->loginRequired();
} else {
return false;
}
};
}
示例8: init
/**
* Initializes the [[rules]] array by instantiating rule objects from configurations.
*/
public function init()
{
parent::init();
}
示例9: init
/**
* Set custom ruleConfig
*/
public function init()
{
$this->ruleConfig = ['class' => 'frontend\\libraries\\filters\\AccessRule'];
parent::init();
}