Пример #1
0
 public function PosterMessageAction()
 {
     $username = $this->get('security.context')->getToken()->getUser()->getUsername();
     $message = new NotificationMessage();
     $message->setFrom($username)->setSubject('Nouveau message')->setContent('Contenu');
     $form = $this->generateForm('BFDemoBundle:form:PosterMessage', $message);
     $request = $this->get('request');
     if ('POST' == $request->getMethod()) {
         $form->submit($request);
         if ($form->isValid()) {
             $notifier = $this->get('bf13.app.notification');
             $notifier->addMessage($message);
             $this->addSuccessMessage('Votre message a été posté.');
             $url = $this->generateUrl('bf_demo_user_messages');
             return $this->redirect($url);
         }
     }
     return $this->render('BFDemoBundle:User/Message:add.html.twig', array('form' => $form->createView()));
 }
Пример #2
0
 public function addMessage(NotificationMessage $message, $disable_check = false)
 {
     $InstantMessage = $this->domainRepository->getHandler('BF13BusinessApplicationBundle:InstantMessage')->create();
     $InstantMessage->setFromUser($message->getFrom());
     $InstantMessage->setToUser($message->getTo());
     $InstantMessage->setSubject($message->getSubject());
     $InstantMessage->setContent($message->getContent());
     $InstantMessage->setWasRead(0);
     $InstantMessage->setCreatedAt(new \Datetime());
     $this->domainRepository->store($InstantMessage);
     $username = $message->getTo();
     if (!$disable_check) {
         $this->checkNewMessage($username);
     }
     return true;
 }