$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);
Esempio n. 2
0
$title = "Gone Girl";
$year = 2015;
$film = new Film($title, $year, "john dontknow");
echo "New item created using constructor with : title = {$title} and year = {$year} <br />";
echo $film->toString() . "<br /><br />";
echo "Now setting a plot to:<br />";
$film->setPlot("A lot of stuff happens");
echo $film->getPlot() . "<br /><br />";
echo "Now changing the year to :<br />";
$film->setYear("2016");
echo $film->getYear() . "<br /><br />";
echo "Now changing the director to :<br />";
$film->setDirector("Fahim");
echo $film->getDirector() . "<br /><br />";
echo "Now changing the title to :<br />";
$film->setTitle("AIDA");
echo $film->getTitle() . "<br /><br />";
echo "Now the film is: " . $film->toString() . "<br />";
echo "<h4>FilmItem Class Test</h4>";
$newFilm = new Film("E.T. 2", 2020, "Steven Spielberg");
echo $newFilm->toString();
echo "<h4>Collection Class Test</h4>";
echo "<p>Create 3 line of films and add them to the collections</p>";
$filmCollection[] = new Film("First film", 2000, "Tarantino");
$filmCollection[] = new Film("Second film", 2005, "Robert Rodriguez");
$filmCollection[] = new Film("Third film", 2010, "Steven Speilberg");
foreach ($filmCollection as $filmSingle) {
    echo $filmSingle->toString() . "<br />";
}
echo "<br/><br/><p>Collection after removing 2nd line film</p>";
unset($filmCollection[1]);