Skip to content
Snippets Groups Projects

Resolve #2991232: Add hasRole method to AccountProxy and UserSession classes.

5 files
+ 66
0
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -98,6 +98,22 @@ public function getRoles($exclude_locked_roles = FALSE) {
@@ -98,6 +98,22 @@ public function getRoles($exclude_locked_roles = FALSE) {
return $this->getAccount()->getRoles($exclude_locked_roles);
return $this->getAccount()->getRoles($exclude_locked_roles);
}
}
 
/**
 
* Whether a user has a certain role.
 
*
 
* @param string $rid
 
* The role ID to check.
 
*
 
* @return bool
 
* Returns TRUE if the user has the role, otherwise FALSE.
 
*
 
* @todo in Drupal 10, add method to Drupal\Core\Session\AccountInterface.
 
* @see https://www.drupal.org/node/3228209
 
*/
 
public function hasRole(string $rid): bool {
 
return $this->getAccount()->hasRole($rid);
 
}
 
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
Loading