public function send($content, $channelId) { $m = new Message(); $m->setContent($content); $m->setChannel($this->getContainer()->get('chat.channel')->find($channelId)); $this->em->persist($m); $this->em->flush(); $message = json_decode($this->serializer->serialize($m, 'json'), true); $message['channel'] = $message['channel']['id']; $message['createdAt'] = date($this->dateformat, strtotime($message['created_at'])); $message['createdBy'] = $message['created_by']; unset($message['created_at']); unset($message['created_by']); unset($message['updated_at']); unset($message['updated_by']); return $message; }
/** * Remove messages * * @param \Siciarek\ChatBundle\Entity\ChatMessage $messages */ public function removeMessage(\Siciarek\ChatBundle\Entity\ChatMessage $messages) { $messages->setChannel($this); $this->messages->removeElement($messages); }