public function PostulerMessagerieAction($idmessage)
 {
     $reponsejson = new JsonResponse();
     $em = $this->getDoctrine()->getEntityManager();
     $message = new Message();
     $date = new \DateTime();
     $message->setDate($date);
     $message->setExpediteur($this->get('security.token_storage')->getToken()->getUser());
     $messagereponse = $em->getRepository('GenericBundle:Message')->find($idmessage);
     $message->setDestinataire($messagereponse->getExpediteur());
     $message->setMission($messagereponse->getMission());
     $message->setMessage('L\'apprenant a donné suite à votre message!');
     $messagereponse->setStatut(1);
     $em->persist($message);
     $em->flush();
     $postulation = new Postulation();
     $postulation->setUser($this->get('security.token_storage')->getToken()->getUser());
     $postulation->setMission($messagereponse->getMission());
     $postulation->setStatut(1);
     $em->persist($postulation);
     $em->flush();
     return $reponsejson->setData(1);
 }
Пример #2
0
 public function PostulerAction($id)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $mission = $em->getRepository('GenericBundle:Mission')->find($id);
     $postdup = $em->getRepository('GenericBundle:Postulation')->findOneBy(array('user' => $user, 'mission' => $mission));
     $reponse = new JsonResponse();
     if ($postdup) {
         return $reponse->setData(0);
     } else {
         $postulation = new Postulation();
         $postulation->setUser($this->get('security.token_storage')->getToken()->getUser());
         $postulation->setMission($mission);
         $postulation->setStatut(1);
         $em->persist($postulation);
         $em->flush();
         return $reponse->setData(1);
     }
 }