public function createAction() { $request = $this->getRequest(); $requestData = $request->request->all(); $em = $this->getDoctrine()->getManager(); $response = new ResponseHelper($this); $pot = new Pot(); $pot->setManager($this->getUser()); $form = $this->createForm(new PotType(), $pot); $form->submit($request); if ($form->isValid()) { $em->persist($pot); $em->flush(); $participation = new Participation(); $participation->setUser($this->getUser()); $participation->setPot($pot); //Automatic acceptance and payment by manager $participation->setAcceptedAt(new \DateTime()); //$participation->setPaidAt(new \DateTime()); $em->persist($participation); $em->flush(); $response->setStatusCode(Response::HTTP_CREATED); $response->addHeader('Location', $this->generateUrl('pots_read', array('id' => $pot->getId()), true)); } else { $response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY); } return $response->renderResponse(); }
public function mainpotAction() { $em = $this->getDoctrine()->getManager(); $rep = $em->getRepository('EUMainBundle:Pot'); $mainPot = $rep->find(1); $user = $this->getUser(); $participation = new Participation(); $participation->setUser($user); $participation->setPot($mainPot); $participation->setAcceptedAt(new \DateTime()); $em->persist($participation); $em->flush(); return $this->redirectToRoute('pots_list'); }