$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);