/** * @Route("/unsubscribe/{id}", name="event_unsubscribe", requirements={"id" = "\d+"}) * @Template() * @ParamConverter("Event", class="ConnectionEventBundle:Event") */ public function unSubscribeAction(Event $event) { if (!($user = $this->getUser())) { throw new AccessDeniedException("Not Logged IN"); } if ($event->hasParticipant($user)) { $user->getParticipateEvents()->removeElement($event); $em = $this->getDoctrine()->getManager(); $em->persist($user); $em->flush(); } return new JsonResponse(); }
/** * {@inheritDoc} */ public function hasParticipant(\Connection\UserBundle\Entity\User $user) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasParticipant', array($user)); return parent::hasParticipant($user); }