Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

68 lines
2.0KB

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