models/AuthItem.php
public static function checkAccess($permissionName, $user = false, $params = [])
    {
        if (is_array($permissionName)) {
            $permissionName = self::createPermissionName($permissionName);
        }
        if (!$user) {
            $user = Yii::$app->user;
        }

        if (!$user->isGuest && !isset(self::$userRoles[$user->id])) {
            self::$userRoles[$user->id] = Yii::$app->authManager->getRolesByUser($user->id);
        }

        if (isset(self::$userRoles[$user->id][self::ROLE_ROOT])) {
            return true;
        }

        if (!self::$defaultRoles) {
            self::setDefaultRoles($user->id);
        }
        if (in_array($permissionName, self::$defaultRoles)) {
            return true;
        }

        return $user->can($permissionName, $params);
    }
public static function checkAccess($permissionName, $user = false, $params = [])
    {
        if (is_array($permissionName)) {
            $permissionName = self::createPermissionName($permissionName);
        }
        if (!$user) {
            $user = Yii::$app->user;
        }

        if (!$user->isGuest && !isset(self::$userRoles[$user->id])) {
            self::$userRoles[$user->id] = Yii::$app->authManager->getRolesByUser($user->id);
        }

        if (isset(self::$userRoles[$user->id][self::ROLE_ROOT])) {
            return true;
        }

        if (!self::$defaultRoles) {
            self::setDefaultRoles($user->id);
        }
        if (in_array($permissionName, self::$defaultRoles)) {
            return true;
        }

        return $user->can($permissionName, $params);
    }
public static function checkAccess ( $ permissionName , $ user = false , $ params = [ ] ) { if ( is_array ( $ permissionName ) ) { $ permissionName = self :: createPermissionName ( $ permissionName ) ; } if ( ! $ user ) { $ user = Yii :: $ app -> user ; } if ( ! $ user -> isGuest && ! isset ( self :: $ userRoles [ $ user -> id ] ) ) { self :: $ userRoles [ $ user -> id ] = Yii :: $ app -> authManager -> getRolesByUser ( $ user -> id ) ; } if ( isset ( self :: $ userRoles [ $ user -> id ] [ self :: ROLE_ROOT ] ) ) { return true ; } if ( ! self :: $ defaultRoles ) { self :: setDefaultRoles ( $ user -> id ) ; } if ( in_array ( $ permissionName , self :: $ defaultRoles ) ) { return true ; } return $ user -> can ( $ permissionName , $ params ) ; }
Check whether the user has access to permission.
@param mixed $permissionName permission name or its components for self::createPermissionName.
@param mixed $user user
@param array $params
@return boolean whether user has access to permission name.
Check whether the user has access to permission .