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