public function findByMessages(User $user, array $messages)
    {
        $messageIds = array();

        foreach ($messages as $message) {
            $messageIds[] = $message->getId();
        }

        $dql = '
            SELECT um
            FROM Claroline\MessageBundle\Entity\UserMessage um
            JOIN um.user u
            JOIN um.message m
            WHERE m.id IN (:messageIds)
            AND u.id = :userId
            ORDER BY m.date DESC
        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('messageIds', $messageIds);
        $query->setParameter('userId', $user->getId());

        return $query->getResult();
    }
public function findByMessages(User $user, array $messages)
    {
        $messageIds = array();

        foreach ($messages as $message) {
            $messageIds[] = $message->getId();
        }

        $dql = '
            SELECT um
            FROM Claroline\MessageBundle\Entity\UserMessage um
            JOIN um.user u
            JOIN um.message m
            WHERE m.id IN (:messageIds)
            AND u.id = :userId
            ORDER BY m.date DESC
        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('messageIds', $messageIds);
        $query->setParameter('userId', $user->getId());

        return $query->getResult();
    }
public function findByMessages ( User $ user , array $ messages ) { $ messageIds = array ( ) ; foreach ( $ messages as $ message ) { $ messageIds [ ] = $ message -> getId ( ) ; } $ dql = '
            SELECT um
            FROM Claroline\MessageBundle\Entity\UserMessage um
            JOIN um.user u
            JOIN um.message m
            WHERE m.id IN (:messageIds)
            AND u.id = :userId
            ORDER BY m.date DESC
        ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'messageIds' , $ messageIds ) ; $ query -> setParameter ( 'userId' , $ user -> getId ( ) ) ; return $ query -> getResult ( ) ; }
Finds UserMessage received or sent by a user, filtered by specific messages.

@param User $user
@param array[Message] $messages

@return array[UserMessage]
Finds UserMessage received or sent by a user filtered by specific messages .