UserInterface.php 4.8 KB

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