Esempio n. 1
0
 /**
  * Sends the message by persisting it to the message manager and undeletes
  * the thread for all participants.
  *
  * @param MessageInterface $message
  */
 public function send(MessageInterface $message)
 {
     $this->threadManager->saveThread($message->getThread(), false);
     $this->messageManager->saveMessage($message, false);
     /* Note: Thread::setIsDeleted() depends on metadata existing for all
      * thread and message participants, so both objects must be saved first.
      * We can avoid flushing the object manager, since we must save once
      * again after undeleting the thread.
      */
     $message->getThread()->setIsDeleted(false);
     $this->messageManager->saveMessage($message);
     $this->dispatcher->dispatch(FOSMessageEvents::POST_SEND, new MessageEvent($message));
 }
 public function setVideoFile($video)
 {
     $this->message->setVideoFile($video);
     return $this;
 }
 /**
  * @param  ParticipantInterface $sender
  * @return MessageBuilder (fluent interface)
  */
 public function setSender(ParticipantInterface $sender)
 {
     $this->message->setSender($sender);
     $this->thread->addParticipant($sender);
     return $this;
 }
Esempio n. 4
0
 /**
  * Ensures that the message metadata are up to date
  */
 protected function doMetadata(MessageInterface $message)
 {
     foreach ($message->getThread()->getAllMetadata() as $threadMeta) {
         $meta = $message->getMetadataForParticipant($threadMeta->getParticipant());
         if (!$meta) {
             $meta = $this->createMessageMetadata();
             $meta->setParticipant($threadMeta->getParticipant());
             $message->addMetadata($meta);
         }
     }
 }
Esempio n. 5
0
 /**
  * Saves a message
  *
  * @param MessageInterface $message
  * @param Boolean $andFlush Whether to flush the changes (default true)
  */
 public function saveMessage(MessageInterface $message, $andFlush = true)
 {
     $message->denormalize();
     $this->dm->persist($message);
     if ($andFlush) {
         $this->dm->flush();
     }
 }
Esempio n. 6
0
 public function __construct(MessageInterface $message)
 {
     parent::__construct($message->getThread());
     $this->message = $message;
 }