You are here

public function Account::getRoles in Service Container 7.2

Same name and namespace in other branches
  1. 7 src/Session/Account.php \Drupal\service_container\Session\Account::getRoles()

Returns a list of roles.

Parameters

bool $exclude_locked_roles: (optional) If TRUE, locked roles (anonymous/authenticated) are not returned.

Return value

array List of role IDs.

Overrides AccountInterface::getRoles

File

src/Session/Account.php, line 58
Contains \Drupal\service_container\Session\Account.

Class

Account
Wraps the global user to provide the account interface.

Namespace

Drupal\service_container\Session

Code

public function getRoles($exclude_locked_roles = FALSE) {
  $rids = array_keys($GLOBALS['user']->roles);
  if ($exclude_locked_roles) {
    $rids = array_filter($rids, function ($value) {
      return $value != DRUPAL_ANONYMOUS_RID && $value != DRUPAL_AUTHENTICATED_RID;
    });
  }
  return $rids;
}