Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/user/src/UserInterface.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\user; | |
4 | |
5 use Drupal\Core\Entity\EntityChangedInterface; | |
6 use Drupal\Core\Entity\ContentEntityInterface; | |
7 use Drupal\Core\Session\AccountInterface; | |
8 | |
9 /** | |
10 * Provides an interface defining a user entity. | |
11 * | |
12 * @ingroup user_api | |
13 */ | |
14 interface UserInterface extends ContentEntityInterface, EntityChangedInterface, AccountInterface { | |
15 | |
16 /** | |
17 * Maximum length of username text field. | |
18 * | |
19 * Keep this under 191 characters so we can use a unique constraint in MySQL. | |
20 */ | |
21 const USERNAME_MAX_LENGTH = 60; | |
22 | |
23 /** | |
24 * Only administrators can create user accounts. | |
25 */ | |
26 const REGISTER_ADMINISTRATORS_ONLY = 'admin_only'; | |
27 | |
28 /** | |
29 * Visitors can create their own accounts. | |
30 */ | |
31 const REGISTER_VISITORS = 'visitors'; | |
32 | |
33 /** | |
34 * Visitors can create accounts that only become active with admin approval. | |
35 */ | |
36 const REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL = 'visitors_admin_approval'; | |
37 | |
38 /** | |
39 * New users will be set to the default time zone at registration. | |
40 */ | |
41 const TIMEZONE_DEFAULT = 0; | |
42 | |
43 /** | |
44 * New users will get an empty time zone at registration. | |
45 */ | |
46 const TIMEZONE_EMPTY = 1; | |
47 | |
48 /** | |
49 * New users will select their own timezone at registration. | |
50 */ | |
51 const TIMEZONE_SELECT = 2; | |
52 | |
53 /** | |
54 * Whether a user has a certain role. | |
55 * | |
56 * @param string $rid | |
57 * The role ID to check. | |
58 * | |
59 * @return bool | |
60 * Returns TRUE if the user has the role, otherwise FALSE. | |
61 */ | |
62 public function hasRole($rid); | |
63 | |
64 /** | |
65 * Add a role to a user. | |
66 * | |
67 * @param string $rid | |
68 * The role ID to add. | |
69 */ | |
70 public function addRole($rid); | |
71 | |
72 /** | |
73 * Remove a role from a user. | |
74 * | |
75 * @param string $rid | |
76 * The role ID to remove. | |
77 */ | |
78 public function removeRole($rid); | |
79 | |
80 /** | |
81 * Sets the username of this account. | |
82 * | |
83 * @param string $username | |
84 * The new user name. | |
85 * | |
86 * @return \Drupal\user\UserInterface | |
87 * The called user entity. | |
88 */ | |
89 public function setUsername($username); | |
90 | |
91 /** | |
92 * Returns the hashed password. | |
93 * | |
94 * @return string | |
95 * The hashed password. | |
96 */ | |
97 public function getPassword(); | |
98 | |
99 /** | |
100 * Sets the user password. | |
101 * | |
102 * @param string $password | |
103 * The new unhashed password. | |
104 * | |
105 * @return \Drupal\user\UserInterface | |
106 * The called user entity. | |
107 */ | |
108 public function setPassword($password); | |
109 | |
110 /** | |
111 * Sets the email address of the user. | |
112 * | |
113 * @param string $mail | |
114 * The new email address of the user. | |
115 * | |
116 * @return \Drupal\user\UserInterface | |
117 * The called user entity. | |
118 */ | |
119 public function setEmail($mail); | |
120 | |
121 /** | |
122 * Returns the creation time of the user as a UNIX timestamp. | |
123 * | |
124 * @return int | |
125 * Timestamp of the creation date. | |
126 */ | |
127 public function getCreatedTime(); | |
128 | |
129 /** | |
130 * Sets the UNIX timestamp when the user last accessed the site.. | |
131 * | |
132 * @param int $timestamp | |
133 * Timestamp of the last access. | |
134 * | |
135 * @return \Drupal\user\UserInterface | |
136 * The called user entity. | |
137 */ | |
138 public function setLastAccessTime($timestamp); | |
139 | |
140 /** | |
141 * Returns the UNIX timestamp when the user last logged in. | |
142 * | |
143 * @return int | |
144 * Timestamp of the last login time. | |
145 */ | |
146 public function getLastLoginTime(); | |
147 | |
148 /** | |
149 * Sets the UNIX timestamp when the user last logged in. | |
150 * | |
151 * @param int $timestamp | |
152 * Timestamp of the last login time. | |
153 * | |
154 * @return \Drupal\user\UserInterface | |
155 * The called user entity. | |
156 */ | |
157 public function setLastLoginTime($timestamp); | |
158 | |
159 /** | |
160 * Returns TRUE if the user is active. | |
161 * | |
162 * @return bool | |
163 * TRUE if the user is active, false otherwise. | |
164 */ | |
165 public function isActive(); | |
166 | |
167 /** | |
168 * Returns TRUE if the user is blocked. | |
169 * | |
170 * @return bool | |
171 * TRUE if the user is blocked, false otherwise. | |
172 */ | |
173 public function isBlocked(); | |
174 | |
175 /** | |
176 * Activates the user. | |
177 * | |
178 * @return \Drupal\user\UserInterface | |
179 * The called user entity. | |
180 */ | |
181 public function activate(); | |
182 | |
183 /** | |
184 * Blocks the user. | |
185 * | |
186 * @return \Drupal\user\UserInterface | |
187 * The called user entity. | |
188 */ | |
189 public function block(); | |
190 | |
191 /** | |
192 * Returns the email that was used when the user was registered. | |
193 * | |
194 * @return string | |
195 * Initial email address of the user. | |
196 */ | |
197 public function getInitialEmail(); | |
198 | |
199 /** | |
200 * Sets the existing plain text password. | |
201 * | |
202 * Required for validation when changing the password, name or email fields. | |
203 * | |
204 * @param string $password | |
205 * The existing plain text password of the user. | |
206 * | |
207 * @return $this | |
208 */ | |
209 public function setExistingPassword($password); | |
210 | |
211 /** | |
212 * Checks the existing password if set. | |
213 * | |
214 * @param \Drupal\user\UserInterface $account_unchanged | |
215 * The unchanged user entity to compare against. | |
216 * | |
217 * @return bool | |
218 * TRUE if the correct existing password was provided. | |
219 * | |
220 * @see UserInterface::setExistingPassword() | |
221 */ | |
222 public function checkExistingPassword(UserInterface $account_unchanged); | |
223 | |
224 } |