예제 #1
0
 /**
  * Creates user album (and band if it necessary) using the specified album.
  *
  * @param MetaPlayer\Model\Album $album
  * @param string $source
  * @return MetaPlayer\Model\UserAlbum
  */
 public function createUserAlbumByAlbum(\MetaPlayer\Model\Album $album, $source)
 {
     $band = $album->getBand();
     $userBand = $this->userBandRepository->findOneByBandAndUser($band, $this->securityManager->getUser());
     if ($userBand == null) {
         $userBand = $this->bandManager->createUserBandByBand($band, $source);
     }
     $userAlbum = new \MetaPlayer\Model\UserAlbum($userBand, $album->getTitle(), $album->getReleaseDate(), $source);
     $userAlbum->setAlbum($album);
     $this->userAlbumRepository->persistAndFlush($userAlbum);
     return $userAlbum;
 }