UserManagerInterface.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. /**
  12. * Interface to be implemented by user managers. This adds an additional level
  13. * of abstraction between your application, and the actual repository.
  14. *
  15. * All changes to users should happen through this interface.
  16. *
  17. * The class also contains ACL annotations which will only work if you have the
  18. * SecurityExtraBundle installed, otherwise they will simply be ignored.
  19. *
  20. * @author Gordon Franke <info@nevalon.de>
  21. * @author Thibault Duplessis <thibault.duplessis@gmail.com>
  22. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  23. */
  24. interface UserManagerInterface
  25. {
  26. /**
  27. * Creates an empty user instance.
  28. *
  29. * @return UserInterface
  30. */
  31. public function createUser();
  32. /**
  33. * Deletes a user.
  34. *
  35. * @param UserInterface $user
  36. *
  37. * @return void
  38. */
  39. public function deleteUser(UserInterface $user);
  40. /**
  41. * Finds one user by the given criteria.
  42. *
  43. * @param array $criteria
  44. *
  45. * @return UserInterface
  46. */
  47. public function findUserBy(array $criteria);
  48. /**
  49. * Find a user by its username.
  50. *
  51. * @param string $username
  52. *
  53. * @return UserInterface or null if user does not exist
  54. */
  55. public function findUserByUsername($username);
  56. /**
  57. * Finds a user by its email.
  58. *
  59. * @param string $email
  60. *
  61. * @return UserInterface or null if user does not exist
  62. */
  63. public function findUserByEmail($email);
  64. /**
  65. * Finds a user by its username or email.
  66. *
  67. * @param string $usernameOrEmail
  68. *
  69. * @return UserInterface or null if user does not exist
  70. */
  71. public function findUserByUsernameOrEmail($usernameOrEmail);
  72. /**
  73. * Finds a user by its confirmationToken.
  74. *
  75. * @param string $token
  76. *
  77. * @return UserInterface or null if user does not exist
  78. */
  79. public function findUserByConfirmationToken($token);
  80. /**
  81. * Returns a collection with all user instances.
  82. *
  83. * @return \Traversable
  84. */
  85. public function findUsers();
  86. /**
  87. * Returns the user's fully qualified class name.
  88. *
  89. * @return string
  90. */
  91. public function getClass();
  92. /**
  93. * Reloads a user.
  94. *
  95. * @param UserInterface $user
  96. *
  97. * @return void
  98. */
  99. public function reloadUser(UserInterface $user);
  100. /**
  101. * Updates a user.
  102. *
  103. * @param UserInterface $user
  104. *
  105. * @return void
  106. */
  107. public function updateUser(UserInterface $user);
  108. /**
  109. * Updates the canonical username and email fields for a user.
  110. *
  111. * @param UserInterface $user
  112. *
  113. * @return void
  114. */
  115. public function updateCanonicalFields(UserInterface $user);
  116. /**
  117. * Updates a user password if a plain password is set.
  118. *
  119. * @param UserInterface $user
  120. *
  121. * @return void
  122. */
  123. public function updatePassword(UserInterface $user);
  124. }