/** * Associate a Genre object to this object * through the moviesGenres cross reference table. * * @param Genre $genre The Moviesgenres object to relate * @return void */ public function addGenre($genre) { if ($this->collGenres === null) { $this->initGenres(); } if (!$this->collGenres->contains($genre)) { // only add it if the **same** object is not already associated $moviesgenres = new Moviesgenres(); $moviesgenres->setGenre($genre); $this->addMoviesgenres($moviesgenres); $this->collGenres[] = $genre; } }