Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

69 lines
2.3KB

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