1 | <?php |
||
26 | class MessageRepository extends EntityRepository implements MessageRepositoryInterface |
||
27 | { |
||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | public function save(MessageInterface $message, $flush = true) |
||
32 | { |
||
33 | $em = $this->getEntityManager(); |
||
34 | $em->persist($message); |
||
35 | |||
36 | if ($flush) { |
||
37 | $em->flush(); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | public function getUnreadMessagesFromThreadForParticipant(ParticipantInterface $participant, ThreadInterface $thread) |
||
45 | { |
||
46 | return $this->createQueryBuilder('m') |
||
47 | ->select('m', 'mm') |
||
48 | ->leftJoin('m.messageMeta', 'mm', Join::WITH, 'mm.participant = :participant') |
||
49 | ->setParameter('participant', $participant) |
||
50 | ->where('mm.readStatus != '.MessageMetaInterface::READ_STATUS_READ) |
||
51 | ->andWhere('m.thread = :thread') |
||
52 | ->setParameter('thread', $thread) |
||
53 | ->getQuery() |
||
54 | ->execute(); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function flush() |
||
65 | } |
||
66 |