|
- <?php
-
- namespace Lc\SovBundle\Repository\User;
-
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\AbstractRepository;
- use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
- use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
- use Symfony\Component\Security\Core\User\UserInterface as SfUserInterface;
-
- /**
- * @method UserInterface|null find($id, $lockMode = null, $lockVersion = null)
- * @method UserInterface|null findOneBy(array $criteria, array $orderBy = null)
- * @method UserInterface[] findAll()
- * @method UserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- class UserRepository extends AbstractRepository implements PasswordUpgraderInterface
- {
- public function getInterfaceClass()
- {
- return UserInterface::class;
- }
-
- /**
- * Used to upgrade (rehash) the user's password automatically over time.
- */
- public function upgradePassword(SfUserInterface $user, string $newEncodedPassword): void
- {
- if (!$user instanceof SfUserInterface) {
- throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
- }
-
- $user->setPassword($newEncodedPassword);
- $this->_em->persist($user);
- $this->_em->flush();
- }
-
- public function findByRole($role) {
- return $this->createQueryBuilder('u')
- ->andWhere('u.roles LIKE :role')
- ->setParameter('role', '%'.$role.'%')
- ->getQuery()
- ->getResult();
- }
-
- // /**
- // * @return User[] Returns an array of User objects
- // */
- /*
- public function findByExampleField($value)
- {
- return $this->createQueryBuilder('u')
- ->andWhere('u.exampleField = :val')
- ->setParameter('val', $value)
- ->orderBy('u.id', 'ASC')
- ->setMaxResults(10)
- ->getQuery()
- ->getResult()
- ;
- }
- */
-
- /*
- public function findOneBySomeField($value): ?User
- {
- return $this->createQueryBuilder('u')
- ->andWhere('u.exampleField = :val')
- ->setParameter('val', $value)
- ->getQuery()
- ->getOneOrNullResult()
- ;
- }
- */
- }
|