Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserSession.php

function UserSession::getRoles

Overrides AccountInterface::getRoles

1 call to UserSession::getRoles()
UserSession::hasRole in core/lib/Drupal/Core/Session/UserSession.php
Whether a user has a certain role.

File

core/lib/Drupal/Core/Session/UserSession.php, line 95

Class

UserSession
An implementation of the user account interface for the global user.

Namespace

Drupal\Core\Session

Code

public function getRoles($exclude_locked_roles = FALSE) {
    $roles = $this->roles;
    if ($exclude_locked_roles) {
        $roles = array_values(array_diff($roles, [
            AccountInterface::ANONYMOUS_ROLE,
            AccountInterface::AUTHENTICATED_ROLE,
        ]));
    }
    return $roles;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal