Loading core/lib/Drupal/Core/Session/AccountInterface.php +11 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,17 @@ public function getRoles($exclude_locked_roles = FALSE); */ public function hasPermission(string $permission); /** * 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. */ public function hasRole(string $rid); /** * Returns TRUE if the account is authenticated. * Loading core/lib/Drupal/Core/Session/AccountProxy.php +0 −3 Original line number Diff line number Diff line Loading @@ -106,9 +106,6 @@ public function getRoles($exclude_locked_roles = FALSE) { * * @return bool * Returns TRUE if the user has the role, otherwise FALSE. * * @todo in Drupal 11, 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); Loading core/lib/Drupal/Core/Session/UserSession.php +0 −3 Original line number Diff line number Diff line Loading @@ -108,9 +108,6 @@ public function getRoles($exclude_locked_roles = FALSE) { * * @return bool * Returns TRUE if the user has the role, otherwise FALSE. * * @todo in Drupal 11, add method to Drupal\Core\Session\AccountInterface. * @see https://www.drupal.org/node/3228209 */ public function hasRole(string $rid): bool { return in_array($rid, $this->getRoles(), TRUE); Loading core/modules/user/src/Entity/User.php +1 −1 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ public function getRoles($exclude_locked_roles = FALSE) { /** * {@inheritdoc} */ public function hasRole($rid) { public function hasRole(string $rid) { return in_array($rid, $this->getRoles()); } Loading core/modules/user/src/UserInterface.php +0 −14 Original line number Diff line number Diff line Loading @@ -50,20 +50,6 @@ interface UserInterface extends ContentEntityInterface, EntityChangedInterface, */ const TIMEZONE_SELECT = 2; /** * 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 11, move method to Drupal\Core\Session\AccountInterface. * @see https://www.drupal.org/node/3228209 */ public function hasRole($rid); /** * Add a role to a user. * Loading Loading
core/lib/Drupal/Core/Session/AccountInterface.php +11 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,17 @@ public function getRoles($exclude_locked_roles = FALSE); */ public function hasPermission(string $permission); /** * 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. */ public function hasRole(string $rid); /** * Returns TRUE if the account is authenticated. * Loading
core/lib/Drupal/Core/Session/AccountProxy.php +0 −3 Original line number Diff line number Diff line Loading @@ -106,9 +106,6 @@ public function getRoles($exclude_locked_roles = FALSE) { * * @return bool * Returns TRUE if the user has the role, otherwise FALSE. * * @todo in Drupal 11, 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); Loading
core/lib/Drupal/Core/Session/UserSession.php +0 −3 Original line number Diff line number Diff line Loading @@ -108,9 +108,6 @@ public function getRoles($exclude_locked_roles = FALSE) { * * @return bool * Returns TRUE if the user has the role, otherwise FALSE. * * @todo in Drupal 11, add method to Drupal\Core\Session\AccountInterface. * @see https://www.drupal.org/node/3228209 */ public function hasRole(string $rid): bool { return in_array($rid, $this->getRoles(), TRUE); Loading
core/modules/user/src/Entity/User.php +1 −1 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ public function getRoles($exclude_locked_roles = FALSE) { /** * {@inheritdoc} */ public function hasRole($rid) { public function hasRole(string $rid) { return in_array($rid, $this->getRoles()); } Loading
core/modules/user/src/UserInterface.php +0 −14 Original line number Diff line number Diff line Loading @@ -50,20 +50,6 @@ interface UserInterface extends ContentEntityInterface, EntityChangedInterface, */ const TIMEZONE_SELECT = 2; /** * 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 11, move method to Drupal\Core\Session\AccountInterface. * @see https://www.drupal.org/node/3228209 */ public function hasRole($rid); /** * Add a role to a user. * Loading