src/Repository/Tenant/UserRepository.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Tenant;
  3. use App\Entity\Tenant\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\UserInterface;
  8. /**
  9.  * @method User|null find($id, $lockMode = null, $lockVersion = null)
  10.  * @method User|null findOneBy(array $criteria, array $orderBy = null)
  11.  * @method User[]    findAll()
  12.  * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  13.  */
  14. class UserRepository extends ServiceEntityRepository
  15. {
  16.     /**
  17.      * UserRepository constructor.
  18.      * @param ManagerRegistry $registry
  19.      */
  20.     public function __construct(
  21.         ManagerRegistry $registry
  22.     ) {
  23.         parent::__construct($registryUser::class);
  24.     }
  25.     /**
  26.      * Used to upgrade (rehash) the user's password automatically over time.
  27.      */
  28.     public function upgradePassword(UserInterface $userstring $newEncodedPassword): void
  29.     {
  30.         if (!$user instanceof User) {
  31.             throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
  32.         }
  33.         $user->setPassword($newEncodedPassword);
  34.         $this->_em->persist($user);
  35.         $this->_em->flush();
  36.     }
  37.     public function findOneByEmailOrUsername(string $emailOrUsername)
  38.     {
  39.         return $this->createQueryBuilder('u')
  40.             ->where('u.email = :emailOrUsername')
  41.             ->orWhere('u.name = :emailOrUsername')
  42.             ->setParameter('emailOrUsername'$emailOrUsername)
  43.             ->getQuery()
  44.             ->getOneOrNullResult();
  45.     }
  46.     // /**
  47.     //  * @return User[] Returns an array of User objects
  48.     //  */
  49.     /*
  50.     public function findByExampleField($value)
  51.     {
  52.         return $this->createQueryBuilder('t')
  53.             ->andWhere('t.exampleField = :val')
  54.             ->setParameter('val', $value)
  55.             ->orderBy('t.id', 'ASC')
  56.             ->setMaxResults(10)
  57.             ->getQuery()
  58.             ->getResult()
  59.         ;
  60.     }
  61.     */
  62.     /*
  63.     public function findOneBySomeField($value): ?User
  64.     {
  65.         return $this->createQueryBuilder('t')
  66.             ->andWhere('t.exampleField = :val')
  67.             ->setParameter('val', $value)
  68.             ->getQuery()
  69.             ->getOneOrNullResult()
  70.         ;
  71.     }
  72.     */
  73. }