public function UserSession::getRoles in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Session/UserSession.php \Drupal\Core\Session\UserSession::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
1 call to UserSession::getRoles()
- UserSession::hasPermission in core/
lib/ Drupal/ Core/ Session/ UserSession.php - Checks whether a user has a certain permission.
File
- core/
lib/ Drupal/ Core/ Session/ UserSession.php, line 92
Class
- UserSession
- An implementation of the user account interface for the global user.
Namespace
Drupal\Core\SessionCode
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;
}