Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\user;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
Chris@0
|
6 use Drupal\Core\Session\AccountInterface;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Provides an interface defining a user role entity.
|
Chris@0
|
10 *
|
Chris@0
|
11 * @ingroup user_api
|
Chris@0
|
12 */
|
Chris@0
|
13 interface RoleInterface extends ConfigEntityInterface {
|
Chris@0
|
14
|
Chris@0
|
15 /**
|
Chris@0
|
16 * Role ID for anonymous users; should match what's in the "role" table.
|
Chris@0
|
17 */
|
Chris@0
|
18 const ANONYMOUS_ID = AccountInterface::ANONYMOUS_ROLE;
|
Chris@0
|
19
|
Chris@0
|
20 /**
|
Chris@0
|
21 * Role ID for authenticated users; should match what's in the "role" table.
|
Chris@0
|
22 */
|
Chris@0
|
23 const AUTHENTICATED_ID = AccountInterface::AUTHENTICATED_ROLE;
|
Chris@0
|
24
|
Chris@0
|
25 /**
|
Chris@0
|
26 * Returns a list of permissions assigned to the role.
|
Chris@0
|
27 *
|
Chris@0
|
28 * @return array
|
Chris@0
|
29 * The permissions assigned to the role.
|
Chris@0
|
30 */
|
Chris@0
|
31 public function getPermissions();
|
Chris@0
|
32
|
Chris@0
|
33 /**
|
Chris@0
|
34 * Checks if the role has a permission.
|
Chris@0
|
35 *
|
Chris@0
|
36 * @param string $permission
|
Chris@0
|
37 * The permission to check for.
|
Chris@0
|
38 *
|
Chris@0
|
39 * @return bool
|
Chris@0
|
40 * TRUE if the role has the permission, FALSE if not.
|
Chris@0
|
41 */
|
Chris@0
|
42 public function hasPermission($permission);
|
Chris@0
|
43
|
Chris@0
|
44 /**
|
Chris@0
|
45 * Grant permissions to the role.
|
Chris@0
|
46 *
|
Chris@0
|
47 * @param string $permission
|
Chris@0
|
48 * The permission to grant.
|
Chris@0
|
49 *
|
Chris@0
|
50 * @return $this
|
Chris@0
|
51 */
|
Chris@0
|
52 public function grantPermission($permission);
|
Chris@0
|
53
|
Chris@0
|
54 /**
|
Chris@0
|
55 * Revokes a permissions from the user role.
|
Chris@0
|
56 *
|
Chris@0
|
57 * @param string $permission
|
Chris@0
|
58 * The permission to revoke.
|
Chris@0
|
59 *
|
Chris@0
|
60 * @return $this
|
Chris@0
|
61 */
|
Chris@0
|
62 public function revokePermission($permission);
|
Chris@0
|
63
|
Chris@0
|
64 /**
|
Chris@0
|
65 * Indicates that a role has all available permissions.
|
Chris@0
|
66 *
|
Chris@0
|
67 * @return bool
|
Chris@0
|
68 * TRUE if the role has all permissions.
|
Chris@0
|
69 */
|
Chris@0
|
70 public function isAdmin();
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * Sets the role to be an admin role.
|
Chris@0
|
74 *
|
Chris@0
|
75 * @param bool $is_admin
|
Chris@0
|
76 * TRUE if the role should be an admin role.
|
Chris@0
|
77 *
|
Chris@0
|
78 * @return $this
|
Chris@0
|
79 */
|
Chris@0
|
80 public function setIsAdmin($is_admin);
|
Chris@0
|
81
|
Chris@0
|
82 /**
|
Chris@0
|
83 * Returns the weight.
|
Chris@0
|
84 *
|
Chris@0
|
85 * @return int
|
Chris@0
|
86 * The weight of this role.
|
Chris@0
|
87 */
|
Chris@0
|
88 public function getWeight();
|
Chris@0
|
89
|
Chris@0
|
90 /**
|
Chris@0
|
91 * Sets the weight to the given value.
|
Chris@0
|
92 *
|
Chris@0
|
93 * @param int $weight
|
Chris@0
|
94 * The desired weight.
|
Chris@0
|
95 *
|
Chris@0
|
96 * @return $this
|
Chris@0
|
97 */
|
Chris@0
|
98 public function setWeight($weight);
|
Chris@0
|
99
|
Chris@0
|
100 }
|