|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the FOSUserBundle package. |
|
5 * |
|
6 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace FOS\UserBundle\Model; |
|
13 |
|
14 use Symfony\Component\Security\Core\User\AdvancedUserInterface; |
|
15 |
|
16 /** |
|
17 * @author Thibault Duplessis <thibault.duplessis@gmail.com> |
|
18 * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
19 */ |
|
20 interface UserInterface extends AdvancedUserInterface, \Serializable |
|
21 { |
|
22 /** |
|
23 * Gets the algorithm used to encode the password. |
|
24 * |
|
25 * @return string |
|
26 */ |
|
27 function getAlgorithm(); |
|
28 |
|
29 /** |
|
30 * Sets the algorithm |
|
31 * |
|
32 * @param string $algorithm |
|
33 */ |
|
34 function setAlgorithm($algorithm); |
|
35 |
|
36 /** |
|
37 * Sets the username. |
|
38 * |
|
39 * @param string $username |
|
40 */ |
|
41 function setUsername($username); |
|
42 |
|
43 /** |
|
44 * Gets the canonical username in search and sort queries. |
|
45 * |
|
46 * @return string |
|
47 */ |
|
48 function getUsernameCanonical(); |
|
49 |
|
50 /** |
|
51 * Sets the canonical username. |
|
52 * |
|
53 * @param string $usernameCanonical |
|
54 */ |
|
55 function setUsernameCanonical($usernameCanonical); |
|
56 |
|
57 /** |
|
58 * Gets email. |
|
59 * |
|
60 * @return string |
|
61 */ |
|
62 function getEmail(); |
|
63 |
|
64 /** |
|
65 * Sets the email. |
|
66 * |
|
67 * @param string $email |
|
68 */ |
|
69 function setEmail($email); |
|
70 |
|
71 /** |
|
72 * Gets the canonical email in search and sort queries. |
|
73 * |
|
74 * @return string |
|
75 */ |
|
76 function getEmailCanonical(); |
|
77 |
|
78 /** |
|
79 * Set the canonical email. |
|
80 * |
|
81 * @param string $emailCanonical |
|
82 */ |
|
83 function setEmailCanonical($emailCanonical); |
|
84 |
|
85 /** |
|
86 * Gets the plain password. |
|
87 * |
|
88 * @return string |
|
89 */ |
|
90 function getPlainPassword(); |
|
91 |
|
92 /** |
|
93 * Sets the plain password. |
|
94 * |
|
95 * @param string $password |
|
96 */ |
|
97 function setPlainPassword($password); |
|
98 |
|
99 /** |
|
100 * Sets the hashed password. |
|
101 * |
|
102 * @param string $password |
|
103 */ |
|
104 function setPassword($password); |
|
105 |
|
106 /** |
|
107 * Tells if the the given user has the super admin role. |
|
108 * |
|
109 * @return Boolean |
|
110 */ |
|
111 function isSuperAdmin(); |
|
112 |
|
113 /** |
|
114 * Tells if the the given user is this user. |
|
115 * |
|
116 * Useful when not hydrating all fields. |
|
117 * |
|
118 * @param UserInterface $user |
|
119 * @return Boolean |
|
120 */ |
|
121 function isUser(UserInterface $user = null); |
|
122 |
|
123 /** |
|
124 * @param Boolean $boolean |
|
125 */ |
|
126 function setEnabled($boolean); |
|
127 |
|
128 /** |
|
129 * Sets the locking status of the user. |
|
130 * |
|
131 * @param Boolean $boolean |
|
132 */ |
|
133 function setLocked($boolean); |
|
134 |
|
135 /** |
|
136 * Sets the super admin status |
|
137 * |
|
138 * @param Boolean $boolean |
|
139 */ |
|
140 function setSuperAdmin($boolean); |
|
141 |
|
142 /** |
|
143 * Generates the confirmation token if it is not set. |
|
144 */ |
|
145 function generateConfirmationToken(); |
|
146 |
|
147 /** |
|
148 * Gets the confirmation token. |
|
149 * |
|
150 * @return string |
|
151 */ |
|
152 function getConfirmationToken(); |
|
153 |
|
154 /** |
|
155 * Sets the confirmation token |
|
156 * |
|
157 * @param string $confirmationToken |
|
158 */ |
|
159 function setConfirmationToken($confirmationToken); |
|
160 |
|
161 /** |
|
162 * Sets the timestamp that the user requested a password reset. |
|
163 * |
|
164 * @param \DateTime $date |
|
165 */ |
|
166 function setPasswordRequestedAt(\DateTime $date); |
|
167 |
|
168 /** |
|
169 * Checks whether the password reset request has expired. |
|
170 * |
|
171 * @param integer $ttl Requests older than this many seconds will be considered expired |
|
172 * @return Boolean true if the user's password request is non expired, false otherwise |
|
173 */ |
|
174 function isPasswordRequestNonExpired($ttl); |
|
175 |
|
176 /** |
|
177 * Sets the last login time |
|
178 * |
|
179 * @param \DateTime $time |
|
180 */ |
|
181 function setLastLogin(\DateTime $time); |
|
182 |
|
183 /** |
|
184 * Never use this to check if this user has access to anything! |
|
185 * |
|
186 * Use the SecurityContext, or an implementation of AccessDecisionManager |
|
187 * instead, e.g. |
|
188 * |
|
189 * $securityContext->isGranted('ROLE_USER'); |
|
190 * |
|
191 * @param string $role |
|
192 * @return Boolean |
|
193 */ |
|
194 function hasRole($role); |
|
195 |
|
196 /** |
|
197 * Sets the roles of the user. |
|
198 * |
|
199 * This overwrites any previous roles. |
|
200 * |
|
201 * @param array $roles |
|
202 */ |
|
203 function setRoles(array $roles); |
|
204 |
|
205 /** |
|
206 * Adds a role to the user. |
|
207 * |
|
208 * @param string $role |
|
209 */ |
|
210 function addRole($role); |
|
211 |
|
212 /** |
|
213 * Removes a role to the user. |
|
214 * |
|
215 * @param string $role |
|
216 */ |
|
217 function removeRole($role); |
|
218 } |