Ejemplo n.º 1
0
 public function addSeance()
 {
     $em = $this->getDoctrine()->getManager();
     $seance = new Seance();
     $seance->setDate(new \DateTime("2016-6-25"));
     $seance->setTypeView("VOSTFR");
     $seance->setDescription("Le DKS dici forte miretur, quod alia quaedam in hoc facultas sit ingeni, neque haec dicendi ratio aut disciplina, ne nos quidem huic uni studio penitus umquam dediti fuimus. Etenim omnes artes, quae ad humanitatem pertinent, habent quoddam commune vinculum, et quasi cognatione quadam inter se continentur. ");
     $seance->setContribution("Chips, soda, coca ou tout ce que vous voulez apporter ");
     $seance->setPrice(6);
     $seance->setMaxPlace(5);
     $address = $em->getRepository('MCBundle:Address')->find(1);
     $seance->setAddress($address);
     $material = $em->getRepository('MCBundle:Material')->find(3);
     $seance->addMaterial($material);
     $material = $em->getRepository('MCBundle:Material')->find(1);
     $seance->addMaterial($material);
     $material = $em->getRepository('MCBundle:Material')->find(2);
     $seance->addMaterial($material);
     $modality = $em->getRepository('MCBundle:Modality')->find(2);
     $seance->setModality($modality);
     $film = $em->getRepository('MCBundle:Film')->find(2);
     $seance->setFilm($film);
     $user = $em->getRepository('UserBundle:User')->find(1);
     $seance->setCreator($user);
     //        $em->persist($seance);
     //        $em->flush();
     return new Response("Add");
 }
     $view = FOSView::create();
     if (null == $result) {
         $view->setData('Seance deleted')->setStatusCode(200);
     } else {
         $view->setData('Seance don\'t delete')->setStatusCode(404);
     }
     return $view;
 }
 /**
  * Get all Seances by ID Film
  * @ApiDoc(
  *   resource = true,
  *   description = "Get all Seances by ID Film",
  *   statusCodes = {
  *     200 = "Returned when successful",
  *     404 = "Returned when the user is not found"
  *   }
  * )
  * @Get("/seances/film/{idFilm}")
  * @param $idFilm
  * @return View
  */
 public function getSeanceFilmAction($idFilm)
 {
     $em = $this->getDoctrine()->getManager();
     //        $data['film'] = $em->getRepository('MCBundle:Film')->find($idFilm);
     $result = $em->getRepository('MCBundle:Film')->filmIDSeance($idFilm);
     $seance = null;
     $data = array();
     if (count($result) > 0) {
         foreach ($result as $key => $seance) {
             $data[$key]["seance"] = $seance;
             $data[$key]["participants"] = $em->getRepository('MCBundle:Film')->filmSeanceParticipant($seance->getId());
         }
     }
     $view = FOSView::create();
     if ($data !== null) {
         $view->setData($data)->setStatusCode(200);
     } else {
         $view->setData($data)->setStatusCode(404);
     }
     return $view;
 }
 /**
  * Get all Seances of ID User
  * @ApiDoc(
  *   resource = true,
  *   description = "Return all Seances of User",
  *   statusCodes = {
  *     200 = "Returned when successful",
  *     404 = "Returned when the user is not found"
  *   }
  * )
  * @Get("/seances/user/{idUser}")
  * @param $idUser
  * @return View
  */
 public function getSeanceUserAction($idUser)
 {
     $em = $this->getDoctrine()->getManager();
     $seances = $em->getRepository('MCBundle:Seance')->findByCreator($idUser);
     $view = FOSView::create();
     if ($seances) {
         $view->setData($seances)->setStatusCode(200);
     } else {
         $view->setData($seances)->setStatusCode(404);
     }
     return $view;
 }
 /**
  * Create a seance from the submitted data.<br/>
  * @ApiDoc(
  *   resource = true,
  *   description = "Create a new seance from the submitted data.",
  *   statusCodes = {
  *     200 = "Returned when successful",
  *     400 = "Returned when the form has errors"
  *   }
  * )
  * @param ParamFetcher $paramFetcher Paramfetcher
  *
  * @RequestParam(name="idUser", nullable=false, strict=true, description="id de l'utilisateur.")
  * @RequestParam(name="date", nullable=false, strict=true, description="Date de la séance.")
  * @RequestParam(name="typeView", nullable=false, strict=true, description="Type de visionnage.")
  * @RequestParam(name="description", nullable=false, strict=true, description="Description de l'annonce.")
  * @RequestParam(name="contribution", nullable=false, strict=true, description="Contribution.")
  * @RequestParam(name="price", nullable=false, strict=true, description="Prix.")
  * @RequestParam(name="idAddress", nullable=false, strict=true, description="Id Adresse de l'utilisateur.")
  * @RequestParam(name="maxPlace", nullable=false, strict=true, description="ID de l'adresse.")
  * @RequestParam(name="idModality", nullable=false, strict=true, description="ID modalité.")
  * @RequestParam(name="ISAN", nullable=false, strict=true, description="Code du film.")
  *
  * @return View
  */
 public function postSeancesAction(ParamFetcher $paramFetcher)
 {
     $em = $this->getDoctrine()->getManager();
     $objSeance = new Seance();
     $user = $em->getRepository('UserBundle:User')->find($paramFetcher->get('idUser'));
     $objSeance->setCreator($user);
     $objSeance->setDate(new \DateTime($paramFetcher->get('date')));
     $objSeance->setTypeView($paramFetcher->get('typeView'));
     $objSeance->setDescription($paramFetcher->get('description'));
     $objSeance->setContribution($paramFetcher->get('contribution'));
     $objSeance->setPrice($paramFetcher->get('price'));
     $objSeance->setDisable(true);
     $objSeance->setMaxPlace($paramFetcher->get('maxPlace'));
     if ($paramFetcher->get('idAddress')) {
         $address = $em->getRepository('MCBundle:Address')->find($paramFetcher->get('idAddress'));
         $objSeance->setAddress($address);