5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
6 use Drupal\Core\Session\AccountInterface;
9 * Provides an interface defining a user role entity.
13 interface RoleInterface extends ConfigEntityInterface {
16 * Role ID for anonymous users; should match what's in the "role" table.
18 const ANONYMOUS_ID = AccountInterface::ANONYMOUS_ROLE;
21 * Role ID for authenticated users; should match what's in the "role" table.
23 const AUTHENTICATED_ID = AccountInterface::AUTHENTICATED_ROLE;
26 * Returns a list of permissions assigned to the role.
29 * The permissions assigned to the role.
31 public function getPermissions();
34 * Checks if the role has a permission.
36 * @param string $permission
37 * The permission to check for.
40 * TRUE if the role has the permission, FALSE if not.
42 public function hasPermission($permission);
45 * Grant permissions to the role.
47 * @param string $permission
48 * The permission to grant.
52 public function grantPermission($permission);
55 * Revokes a permissions from the user role.
57 * @param string $permission
58 * The permission to revoke.
62 public function revokePermission($permission);
65 * Indicates that a role has all available permissions.
68 * TRUE if the role has all permissions.
70 public function isAdmin();
73 * Sets the role to be an admin role.
75 * @param bool $is_admin
76 * TRUE if the role should be an admin role.
80 public function setIsAdmin($is_admin);
86 * The weight of this role.
88 public function getWeight();
91 * Sets the weight to the given value.
98 public function setWeight($weight);