Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

75 Zeilen
2.5KB

  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. public function findByRole($role) {
  33. return $this->createQueryBuilder('u')
  34. ->andWhere('u.roles LIKE :role')
  35. ->setParameter('role', '%'.$role.'%')
  36. ->getQuery()
  37. ->getResult();
  38. }
  39. // /**
  40. // * @return User[] Returns an array of User objects
  41. // */
  42. /*
  43. public function findByExampleField($value)
  44. {
  45. return $this->createQueryBuilder('u')
  46. ->andWhere('u.exampleField = :val')
  47. ->setParameter('val', $value)
  48. ->orderBy('u.id', 'ASC')
  49. ->setMaxResults(10)
  50. ->getQuery()
  51. ->getResult()
  52. ;
  53. }
  54. */
  55. /*
  56. public function findOneBySomeField($value): ?User
  57. {
  58. return $this->createQueryBuilder('u')
  59. ->andWhere('u.exampleField = :val')
  60. ->setParameter('val', $value)
  61. ->getQuery()
  62. ->getOneOrNullResult()
  63. ;
  64. }
  65. */
  66. }