You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2KB

  1. <?php
  2. namespace Lc\SovBundle\Repository\User;
  3. use Lc\SovBundle\Model\User\UserInterface;
  4. use Lc\SovBundle\Repository\AbstractRepository;
  5. use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
  6. use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface as SfUserInterface;
  8. /**
  9. * @method UserInterface|null find($id, $lockMode = null, $lockVersion = null)
  10. * @method UserInterface|null findOneBy(array $criteria, array $orderBy = null)
  11. * @method UserInterface[] findAll()
  12. * @method UserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  13. */
  14. class UserRepository extends AbstractRepository implements PasswordUpgraderInterface
  15. {
  16. public function getInterfaceClass()
  17. {
  18. return UserInterface::class;
  19. }
  20. /**
  21. * Used to upgrade (rehash) the user's password automatically over time.
  22. */
  23. public function upgradePassword(SfUserInterface $user, string $newEncodedPassword): void
  24. {
  25. if (!$user instanceof SfUserInterface) {
  26. throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
  27. }
  28. $user->setPassword($newEncodedPassword);
  29. $this->_em->persist($user);
  30. $this->_em->flush();
  31. }
  32. // /**
  33. // * @return User[] Returns an array of User objects
  34. // */
  35. /*
  36. public function findByExampleField($value)
  37. {
  38. return $this->createQueryBuilder('u')
  39. ->andWhere('u.exampleField = :val')
  40. ->setParameter('val', $value)
  41. ->orderBy('u.id', 'ASC')
  42. ->setMaxResults(10)
  43. ->getQuery()
  44. ->getResult()
  45. ;
  46. }
  47. */
  48. /*
  49. public function findOneBySomeField($value): ?User
  50. {
  51. return $this->createQueryBuilder('u')
  52. ->andWhere('u.exampleField = :val')
  53. ->setParameter('val', $value)
  54. ->getQuery()
  55. ->getOneOrNullResult()
  56. ;
  57. }
  58. */
  59. }