public function addMovieCast($tmdbCredits, $newMovie) { if (!$this->isMovieCastExist($newMovie)) { $tmdbCastMembers = $this->getCastMembers($tmdbCredits); // dump($tmdbCastMembers); foreach ($tmdbCastMembers as $tmdbMember) { $id = $tmdbMember->getId(); $person = $this->getPerson($id); // dump($person); $movieCast = new MovieCast(); $movieCast->hydrate($tmdbMember); $newMovie->addMovieCast($movieCast); $person->addMovieCast($movieCast); //$movieCast->setMovie($newMovie); //$movieCast->setPerson($person); $this->persist($movieCast); } } //$this->flush(); }
/** * Add movie_cast * * @param bestophe\VideoCollectionBundle\Entity\MovieCast $movie_cast * @return Person */ public function addMovieCast(MovieCast $movie_cast) { $this->movie_cast[] = $movie_cast; $movie_cast->setMovie($this); return $this; }