Пример #1
1
 public function ajaxStoreEventAction(Request $request)
 {
     if ($request->isXMLHttpRequest()) {
         $em = $this->getDoctrine()->getManager();
         $playerIds = $request->get('player_ids');
         //actually emails
         $eventId = $request->get('event_id');
         $event = $this->getDoctrine()->getRepository("SportnetzwerkSpnBundle:Events")->findById($eventId);
         $event[0]->setEventStatus(1);
         //set activation flag
         $created = $event[0]->getCreated();
         foreach ($playerIds as $k => $p) {
             $player = $this->getDoctrine()->getRepository("SportnetzwerkSpnBundle:Player")->findByEmail($p);
             $token = md5($eventId . $player[0]->getName() . $player[0]->getEmail() . $created);
             $playerEvent = new PlayerEvents();
             $playerEvent->setEvent($event[0]);
             $playerEvent->setPlayer($player[0]);
             $playerEvent->setToken($token);
             $em->persist($playerEvent);
             $em->flush();
             $token = $this->getDoctrine()->getRepository("SportnetzwerkSpnBundle:PlayerEvents")->getEventToken($player[0], $eventId);
             $message = \Swift_Message::newInstance()->setSubject('Event invitation - Sportnetzwerk')->setFrom('*****@*****.**')->setTo($player[0]->getEmail())->setBody($this->render('SportnetzwerkSpnBundle:Events:eventInvitationEmail.txt.twig', array('player' => $player[0], 'token' => $token, 'newschedule' => true)));
             $this->get('mailer')->send($message);
         }
         return new JsonResponse(true);
     }
     return new Response('No ajax here', 400);
 }
Пример #2
0
 public function setPlayer($players)
 {
     foreach ($players as $p) {
         $pl = new PlayerEvents();
         $pl->setEvent($this);
         $pl->setPlayer($p);
         $this->addPe($pl);
     }
 }