コード例 #1
0
  *   description = "Delete an Film identified by ID",
  *   statusCodes = {
  *     200 = "Returned when successful",
  *     404 = "Returned when the user is not found"
  *   }
  * )
  * @Delete("/films/delete/{id}")
  * @param int $id the Film id
  * @return View
  */
 public function removeFilmAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $film = $em->getRepository('MCBundle:Film')->find($id);
     $em->remove($film);
     $em->flush();
     $result = $em->getRepository('MCBundle:Film')->find($id);
     $view = FOSView::create();
     if (null == $result) {
         $view->setData('Film deleted')->setStatusCode(200);
     } else {
         $view->setData('Film don\'t delete')->setStatusCode(404);
     }
     return $view;
 }
 /**
コード例 #2
0
 public function parserMovie($movie)
 {
     $film = new Film();
     if (!empty($movie)) {
         $em = $this->getDoctrine()->getManager();
         $film->setISAN($movie->code);
         $film->setTitle($movie->title);
         if (array_key_exists('originalTitle', $movie)) {
             $film->setOriginalTitle($movie->originalTitle);
         }
         if (array_key_exists('release', $movie)) {
             $film->setReleaseDate($movie->release->releaseDate);
         }
         if (array_key_exists('castingShort', $movie)) {
             $film->setDirectors($movie->castingShort->directors);
         }
         if (array_key_exists('castingShort', $movie)) {
             $film->setActors($movie->castingShort->actors);
         }
         if (array_key_exists('nationality', $movie)) {
             $nationality = "";
             foreach ($movie->nationality as $data) {
                 $nationality .= $this->get("mc_allocine")->getObject($data);
             }
             $film->setNationality($nationality);
         }
         if (array_key_exists('runtime', $movie)) {
             $film->setRuntime($movie->runtime);
         }
         $film->setAgeLimit(10);
         if (array_key_exists('statistics', $movie) && array_key_exists('pressRating', $movie->statistics)) {
             $film->setPressRating($movie->statistics->pressRating);
         }
         if (array_key_exists('statistics', $movie) && array_key_exists('userRating', $movie->statistics)) {
             $film->setUserRating($movie->statistics->userRating);
         }
         if (array_key_exists('link', $movie)) {
             if (!empty($movie->link)) {
                 $film->setLink($movie->link[0]->href);
             }
         }
         if (array_key_exists('trailerEmbed', $movie)) {
             $film->setTrailer($movie->trailerEmbed);
         }
         if (array_key_exists('poster', $movie) && array_key_exists('href', $movie->poster)) {
             $film->setPoster($movie->poster->href);
         }
         if (array_key_exists('synopsis', $movie)) {
             $film->setSynopsis($movie->synopsis);
         }
         if (array_key_exists('synopsisShort', $movie)) {
             $film->setSynopsisShort($movie->synopsisShort);
         }
         if (array_key_exists('genre', $movie)) {
             foreach ($movie->genre as $data) {
                 $genre = $this->get("mc_allocine")->getObject($data);
                 $objGenre = $em->getRepository('MCBundle:Genre')->findOneByTitle($genre);
                 if (!$objGenre) {
                     $objGenre = new Genre();
                     $objGenre->setTitle($genre);
                     $em->persist($objGenre);
                     $em->flush();
                     $objGenre = $em->getRepository('MCBundle:Genre')->findOneByTitle($genre);
                 }
                 $film->addGenre($objGenre);
             }
         }
     }
     return $film;
 }