Add findAllForAttendee method in NotificationRepository

This commit is contained in:
Marc Ducobu 2021-06-18 17:19:39 +02:00
parent e50bfd5129
commit 6ea5a3088c

View File

@ -23,6 +23,7 @@ use Chill\MainBundle\Entity\Notification;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository; use Doctrine\Persistence\ObjectRepository;
use Chill\MainBundle\Entity\User;
final class NotificationRepository implements ObjectRepository final class NotificationRepository implements ObjectRepository
{ {
@ -59,8 +60,24 @@ final class NotificationRepository implements ObjectRepository
return $this->repository->findBy($criteria, $orderBy, $limit, $offset); 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() { public function getClassName() {
return Notification::class; return Notification::class;
} }
} }