From 6ea5a3088c2a5e133c18d8c003163eddac1a7a23 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 18 Jun 2021 17:19:39 +0200 Subject: [PATCH] Add findAllForAttendee method in NotificationRepository --- .../Repository/NotificationRepository.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index 844459f8b..d52817164 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -23,6 +23,7 @@ use Chill\MainBundle\Entity\Notification; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\Persistence\ObjectRepository; +use Chill\MainBundle\Entity\User; final class NotificationRepository implements ObjectRepository { @@ -59,8 +60,24 @@ final class NotificationRepository implements ObjectRepository return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } + /** + * @return Notification[] + */ + public function findAllForAttendee(User $addressee) // TODO passer à attendees avec S + { + $qb = $this->repository->createQueryBuilder('n'); + + $qb + ->select('n') + ->join('n.addressees', 'a') + ->where('a = :addressee') + ->setParameter('addressee', $addressee); + + $query = $qb->getQuery(); + return $qb->getQuery()->getResult(); + } + public function getClassName() { return Notification::class; } - }