matchRole() защищенный Метод

protected matchRole ( User $user ) : boolean
$user yii\web\User the user object
Результат boolean whether the rule applies to the role
Пример #1
0
 /**
  * @inheritdoc
  */
 protected function matchRole($user)
 {
     if (System::loadConfig('enable_memmber_login')) {
         return parent::matchRole($user);
     } else {
         Yii::$app->user->logout();
         Yii::$app->getResponse()->redirect('/site/login');
     }
 }
 protected function matchRole($user)
 {
     if (parent::matchRole($user)) {
         return true;
     }
     if (isset(Yii::$app->controller->model)) {
         $this->params = ['model' => Yii::$app->controller->model];
         foreach ($this->roles as $role) {
             if ($user->can($role, $this->params)) {
                 return true;
             }
         }
     }
     return false;
 }