Ejemplo n.º 1
0
 /**
  * @param array $data
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 private function deleteRequestJoinClub(array $data)
 {
     $em = $this->getDoctrine()->getManager();
     $userHasClub = $em->getRepository('FfjvBoBundle:UserHasClubs')->find($data['user_has_club']);
     $em->remove($userHasClub);
     $message = new Messages();
     $message->setAuthorUser($this->getUser());
     $message->setUser($userHasClub->getUser());
     $message->setEmail($userHasClub->getUser()->getEmail());
     $message->setMessage($data['message']);
     $message->setSubject('Demande de rejoindre le club ' . $userHasClub->getClub() . ' refusée');
     $em->persist($message);
     $em->flush();
     $this->get('contact')->sendRequestResponseToJoinCLub($message);
     $this->addFlash('success', 'La reponse a été envoyer');
     return $this->redirectToRoute('fo_clubs_show', array('clubId' => $userHasClub->getClub()->getId()));
 }
Ejemplo n.º 2
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function contactClubAction(Request $request)
 {
     $form = $this->getContactForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $em = $this->getDoctrine()->getManager();
         $id = $data['club'];
         $club = $em->getRepository('FfjvBoBundle:Clubs')->find($id);
         if (!$club) {
             throw $this->createNotFoundException('Unable to find Clubs club.');
         }
         // create and save Mesage
         $message = new Messages();
         $message->setAuthorUser($this->getUser());
         $message->setMessage($data['content']);
         $message->setSubject($data['subject']);
         $message->setClub($club);
         $message->setEmail($club->getEmail());
         $em->persist($message);
         $em->flush();
         //send message
         if ($this->get('contact')->contactClub($message)) {
             $this->addFlash('success', 'Votre message a bien été envoyer');
         } else {
             $this->addFlash('error', 'Une erreur c\'est produite ! Votre message n\'a pus être envoyé .');
         }
         return $this->redirectToRoute('fo_clubs_show', array('clubId' => $club->getId()));
     }
     $this->addFlash('error', 'Une erreur c\'est produite');
     return $this->redirectToRoute('fo_profile_show', array('id' => $this->getUser()->getId()));
 }