/**
  * Saves a movie into the database.
  *
  * @param \MyMovies\Domain\Article $article The article to save
  */
 public function save(Movie $movie)
 {
     $movieData = array('mov_title' => $movie->getTitle(), 'mov_description_long' => $movie->getDescriptionLong(), 'mov_description_short' => $movie->getDescriptionShort(), 'mov_director' => $movie->getDirector(), 'mov_year' => $movie->getYear(), 'mov_image' => $movie->getImage());
     if ($movie->getId()) {
         // The article has already been saved : update it
         $this->getDb()->update('movie', $movieData, array('mov_id' => $movie->getId()));
     } else {
         // The article has never been saved : insert it
         $this->getDb()->insert('movie', $movieData);
         // Get the id of the newly created user and set it on the entity.
         $id = $this->getDb()->lastInsertId();
         $movie->setId($id);
     }
 }
 protected function saveMovieImage(Movie $movie)
 {
     $file = $movie->getImage();
     if (is_null($file)) {
         $fileName = $this->noImagesAvailable;
     } else {
         $name = str_replace(' ', '', $movie->getTitle());
         $name = preg_replace('/[^A-Za-z0-9\\-]/', '', $name);
         //$name = str_replace(array('.', ',', '?', '!', ':', '_', ' ', '.'), '',$movie->getTitle());
         $fileName = $name . "_" . md5(uniqid()) . '.' . $file->guessExtension();
         $brochuresDir = $this->pathImageMovies;
         $file->move($brochuresDir, $fileName);
     }
     $movie->setImage($fileName);
 }