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; } - }