init() публичный Метод

Initializes the [[rules]] array by instantiating rule objects from configurations.
public init ( )
Пример #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->entity) {
         $this->rules = array_merge($this->entity);
     }
     parent::init();
 }
Пример #2
0
 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
0
 /**
  * @see \yii\filters\AccessControl::init()
  */
 public function init()
 {
     parent::init();
     //非正式环境下,每次请求都要对当前页面的权限进行检查
     if (!YII_ENV_PROD) {
         $this->checkAuthItem();
     }
 }
Пример #4
0
 /**
  * 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
0
 public function init()
 {
     parent::init();
     if ($this->user->isGuest) {
         return true;
     }
     if (!$this->Privilege()) {
         die('您没有权限访问这个页面!');
     }
 }
Пример #6
0
 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
0
 /**
  * @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
0
 /**
  * Initializes the [[rules]] array by instantiating rule objects from configurations.
  */
 public function init()
 {
     parent::init();
 }
Пример #9
0
 /**
  * Set custom ruleConfig
  */
 public function init()
 {
     $this->ruleConfig = ['class' => 'frontend\\libraries\\filters\\AccessRule'];
     parent::init();
 }