Check if authenticated user has all roles passed by parameter

@param string[] $roles

@return bool|null return NULL if user is not authenticated
177037
public function hasRoles($roles)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($roles)) {
            $roles = func_get_args();
        }

        // Count roles because user need user to have all roles passed as parameter
        return count(array_intersect($roles, $this->roles)) === count($roles);
    }
37671
public function hasRole($role, $all = false)
    {
        if ($this->isPretendEnabled()) {
            return $this->pretend('hasRole');
        }

        if (!$all) {
            return $this->hasOneRole($role);
        }

        return $this->hasAllRoles($role);
    }
1290577
public function handle($roles)
    {
        if ($this->auth->check()) {
            return $this->auth->user()->hasRole($roles);
        }

        return false;
    }
459017
public function hasRole(...$roles)
    {
        $roles = array_flatten($roles);

        foreach ($roles as $role) {
            $name = $role instanceof Role ? $role->name : $role;

            if ($this->roles->contains('name', $name)) {
                return true;
            }
        }

        return false;
    }
956769
public function hasUserRoles($roles)
	{
		if ($this->session_machine === null) {
			throw new RuntimeException('Session machine not ready ‒ '.__METHOD__.' called too soon.');
		}

		if (is_array($roles)) {
			return count(array_intersect($this->getUserRoles(), $roles)) > 0;
		} else {
			return in_array($roles, $this->getUserRoles());
		}
	}
758347
private function hasRole($role) {

        if (substr($role, 0, 4) !== 'urn:')
        {
            $role = 'urn:lti:role:ims/lis/' . $role;
        }

        return in_array($role, $this->roles);

    }
925350
public function checkAccess($role){
		if(!\Yii::$app->user->isGuest)
		{
			if(Yii::$app->user->identity->role == self::$roles[$role])
			{
				return true;
			}
		}
		return false;
	}
188528
public static function userHasRole($role , $username = null)
	{
		if ( is_null( $username ) ) $username = self::getCurrentUsername();
		if ( is_null( $username ) ) return false;
		if ( ! self::userExists( $username ) ) return false;
		if ( in_array( 'admin' , self::$auth['users'][ $username ]['roles'] ) ) return true;
		return ( in_array( $role , self::$auth['users'][ $username ]['roles'] ) );
	}
160686
public function hasGroups($groups)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($groups)) {
            $groups = func_get_args();
        }

        // Count roles because user need user to have all roles passed as parameter
        return count(array_intersect($groups, $this->groups)) === count($groups);
    }
1072996
public static function hasRole($role)
    {
        if (!isset($_SESSION['user'])) {
            return false;
        };
        if (!isset($_SESSION['ACL_ROLES'])) {
            return false;
        };
        return in_array($role, $_SESSION['ACL_ROLES']);
    }
460109
public static function roleExists($role) : bool {
		if (empty($_SESSION['numbers']['user']['roles'])) return false;
		if (is_array($role)) {
			$temp = array_intersect($role, $_SESSION['numbers']['user']['roles']);
			return !empty($temp);
		} else {
			return in_array($role, $_SESSION['numbers']['user']['roles']);
		}
	}
960731
public static function hasRoleId($role)
    {
        return (self::isFeUser()
            && self::isAuthenticated()
            && in_array($role, $GLOBALS['TSFE']->fe_user->groupData['uid'])
        );
    }
649575
public function isGranted($roles)
    {
        $this->parseRoles();

        $roles = (array) $roles;
        $intersection = array_intersect($roles, $this->roles);

        return count($intersection) > 0;
    }
429894
public function setRoles(array $roles = array())
    {
        if ($this->instance instanceof \Phavour\Session\Storage) {
            if ($this->instance->isLocked()) {
                $this->instance->unlock();
            }
            $this->instance->set('roles', $roles);
            $this->instance->lock();
            return true;
        }

        return false;
    }
525191
public function getAccessibleRoles(array $roles)
    {
        $accessibleRoles = $roles;
        foreach ($roles as $role) {
            /**
             * @var $role Role
             */
            if (isset($this->map[$role->getRole()])) {
                foreach ($this->map[$role->getRole()] as $r) {
                    $accessibleRoles[] = new Role($r);
                }
            }
        }

        return $accessibleRoles;
    }
1015011
public function hasRoleWithName(string $role): bool
    {
        $this->compileUserRoles();

        return in_array($role, $this->userRoles);
    }
1324580
public function isGranted($user, $role)
    {
        if (true === $user->hasRole($role)) {
            return true;
        }

        $roleHierarchy = new RoleHierarchy($this->getRoleHierarchyRoles());

        $userRoles = array_map(function ($role) {
            return new Role($role);
        }, $user->getRoles());

        $roles = $roleHierarchy->getReachableRoles($userRoles);
        $roles = array_map(function (Role $role) {
            return $role->getRole();
        }, $roles);

        return in_array($role, $roles);
    }