Пример #1
0
 /** @ORM\PostUpdate */
 public function postUpdate(Message $message, LifecycleEventArgs $event)
 {
     $entityManager = $event->getEntityManager();
     if ($message->getType() == 1) {
         $cacheDriver = $entityManager->getConfiguration()->getResultCacheImpl();
         $cacheDriver->delete('getUnreadPrestationMessages_' . $message->getReceiver()->getId() . '_' . $message->getPrestation()->getId());
         $cacheDriver->delete('getUnreadPrestationsMessages_' . $message->getReceiver()->getId());
     }
 }
Пример #2
0
 /**
  * 
  * @param Prestation $prestation
  * @param User $sender
  * @param User $receiver
  * @param unknown $type
  * @param unknown $content
  * @return boolean
  */
 protected function createMessage(Prestation $prestation = null, User $sender, User $receiver, $type, $content)
 {
     $message = new Message();
     $message->setType($type);
     $message->setPrestation($prestation);
     $message->setSender($sender);
     $message->setReceiver($receiver);
     $message->setContent($content);
     try {
         $this->em->persist($message);
         $this->em->flush();
         $this->mailer->messageNotification($message);
         return true;
     } catch (\Exception $e) {
         $this->logger->error($e->getMessage());
         return false;
     }
 }
Пример #3
0
 /**
  * [messageNotification description]
  * @param  Message $message [description]
  * @return [type]           [description]
  */
 public function messageNotification(Message $message)
 {
     $to = $message->getReceiver()->getEmail();
     $template = 'MainCommonBundle:Emails\\Messages:prestation.html.twig';
     $subject = $this->translator->trans('prestation.message.subject', array(), 'email');
     $from = self::EMAIL;
     if ($to == $message->getPrestation()->getClient()->getEmail()) {
         $body = $this->templating->render($template, array('prestation' => $message->getPrestation(), 'user' => $message->getReceiver(), 'base_url' => $this->front, 'type' => 1));
     } else {
         $body = $this->templating->render($template, array('prestation' => $message->getPrestation(), 'user' => $message->getReceiver(), 'base_url' => $this->community, 'type' => 2));
     }
     $send = $this->canReceiveEmails($message->getReceiver(), 2);
     if ($send) {
         $this->sendMessage($from, $to, $subject, $body);
     }
 }