src/Repository/Security/UserRepository.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Security;
  3. use App\Entity\Security\User;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. /**
  7.  * @extends ServiceEntityRepository<User>
  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.     public function __construct(ManagerRegistry $registry)
  17.     {
  18.         parent::__construct($registryUser::class);
  19.     }
  20.     public function add(User $entitybool $flush false): void
  21.     {
  22.         $this->getEntityManager()->persist($entity);
  23.         if ($flush) {
  24.             $this->getEntityManager()->flush();
  25.         }
  26.     }
  27.     public function remove(User $entitybool $flush false): void
  28.     {
  29.         $this->getEntityManager()->remove($entity);
  30.         if ($flush) {
  31.             $this->getEntityManager()->flush();
  32.         }
  33.     }
  34. //    /**
  35. //     * @return User[] Returns an array of User objects
  36. //     */
  37. //    public function findByExampleField($value): array
  38. //    {
  39. //        return $this->createQueryBuilder('u')
  40. //            ->andWhere('u.exampleField = :val')
  41. //            ->setParameter('val', $value)
  42. //            ->orderBy('u.id', 'ASC')
  43. //            ->setMaxResults(10)
  44. //            ->getQuery()
  45. //            ->getResult()
  46. //        ;
  47. //    }
  48. //    public function findOneBySomeField($value): ?User
  49. //    {
  50. //        return $this->createQueryBuilder('u')
  51. //            ->andWhere('u.exampleField = :val')
  52. //            ->setParameter('val', $value)
  53. //            ->getQuery()
  54. //            ->getOneOrNullResult()
  55. //        ;
  56. //    }
  57.     
  58.    public function getUserWithoutPerson() {
  59.        // TODO: Take only one which do not have person
  60.        return $this->createQueryBuilder('u')
  61.             ->leftJoin('u.persons''p''WITH'' p is null');
  62.    }
  63. }