コード例 #1
0
 public function getConversations(MessageUserInterface $user)
 {
     $builder = $this->createQueryBuilder('conversation')->innerJoin('conversation.participants', 'participants', 'WITH', 'participants.id = :userId')->setParameter('userId', $user->getId());
     return new ZendPaginator(new DoctrinePaginator(new Paginator($builder->getQuery())));
 }
コード例 #2
0
 public function getMessagesAssociatedWith(MessageUserInterface $user)
 {
     $builder = $this->createQueryBuilder('messages');
     $builder->leftJoin('messages.conversation', 'conversation')->leftJoin('conversation.participants', 'participants')->andWhere($builder->expr()->in('participants', [$user->getId()]))->orderBy('messages.createdAt', 'DESC');
     return new ZendPaginator(new DoctrinePaginator(new Paginator($builder->getQuery())));
 }
コード例 #3
0
 public function markAsReadByUser(MessageEntity $message, MessageUserInterface $user)
 {
     MessageEntity::readByUser($message, new ReadByUserEntry($user->getId(), new DateTime()));
     $this->objectManager->flush();
     $this->getEventManager()->trigger(self::EVENT_READ_BY_USER, $this, ['message' => $message]);
 }