vendor/witalink/starter-bundle/src/Repository/UserRepository.php line 20

Open in your IDE?
  1. <?php
  2. namespace Witalink\StarterBundle\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. abstract class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
  16. {
  17.     public function __construct(ManagerRegistry $registry)
  18.     {
  19.         parent::__construct($registryUser::class);
  20.     }
  21.     /**
  22.      * Used to upgrade (rehash) the user's password automatically over time.
  23.      */
  24.     public function upgradePassword(UserInterface $userstring $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.     public function findByRole($role)
  34.     {
  35.         return $this->createQueryBuilder('u')
  36.             ->andWhere('u.roles LIKE :role')
  37.             ->setParameter('role''%"'.$role.'"%')
  38.             ->getQuery()
  39.             ->getResult();
  40.     }
  41.     // /**
  42.     //  * @return User[] Returns an array of User objects
  43.     //  */
  44.     /*
  45.     public function findByExampleField($value)
  46.     {
  47.         return $this->createQueryBuilder('u')
  48.             ->andWhere('u.exampleField = :val')
  49.             ->setParameter('val', $value)
  50.             ->orderBy('u.id', 'ASC')
  51.             ->setMaxResults(10)
  52.             ->getQuery()
  53.             ->getResult()
  54.         ;
  55.     }
  56.     */
  57.     /*
  58.     public function findOneBySomeField($value): ?User
  59.     {
  60.         return $this->createQueryBuilder('u')
  61.             ->andWhere('u.exampleField = :val')
  62.             ->setParameter('val', $value)
  63.             ->getQuery()
  64.             ->getOneOrNullResult()
  65.         ;
  66.     }
  67.     */
  68. }