示例#1
0
 /**
  * Add track.
  *
  * @param Track $track
  *
  * @return Album
  */
 public function addTrack(Track $track)
 {
     $track->setAlbum($this)->setArtist($this->getArtist())->setLabel($this->getLabel())->setManufacturer($this->getManufacturer())->setPublisher($this->getPublisher())->setReleaseDate($this->getReleaseDate())->setStudio($this->getStudio());
     $this->tracks[] = $track;
     return $this;
 }
示例#2
0
 /**
  * @param AlbumModel $albumModel
  * @param string     $terms
  * @param array      $tracks
  *
  * @return array
  */
 protected function saveTrackList(AlbumModel $albumModel, $terms = '', $tracks = array())
 {
     $trackList = array();
     if ($albumModel->getId()) {
         foreach ($tracks as $position => $title) {
             if ("titre inconnu" == trim(strtolower($title))) {
                 $this->logger->info(sprintf('IGNORING %s - %s TRACK INFOS while processsing %s (album #%s) track list', $terms, $title, $albumModel->getId()));
                 continue;
             }
             try {
                 $this->logger->info(sprintf('Trying to SAVE %s - %s TRACK INFOS using the TrackRetriever', $terms, $title));
                 $trackModel = new Track();
                 $trackModel->fromAlbum($albumModel, $title, $position + 1);
                 // position is an index's an index
                 $this->entityManager->persist($trackModel);
                 $this->entityManager->flush();
                 $trackList[] = $trackModel;
             } catch (InvalidAlbumInputException $e) {
                 $this->logger->error(sprintf('An error occurred : %s', $e));
             }
         }
     }
     return $trackList;
 }