示例#1
0
 public function get(AlbumIdentity $identity)
 {
     $album = $this->redis->get(self::PRE_KEY . $identity->getId());
     if (!$album) {
         $album = $this->repository->get($identity);
         $this->redis->set(self::PRE_KEY . $identity->getId(), $album);
     }
     return $album;
 }
示例#2
0
 /**
  * Retrieves the album with the given identity.
  *
  * @param  AlbumIdentity $identity The identity of the album to retrieve.
  * @return Domain\Entity\Album
  * @throws Domain\Exception\AlbumNotFoundException If no album has the requested identity.
  */
 public function get(AlbumIdentity $identity)
 {
     try {
         $album_raw = $this->spotify_api->getAlbum($identity->getId());
         $album = Album::create($album_raw->id, $album_raw->name);
         foreach ($album_raw->tracks->items as $track) {
             $album->addTrack($this->track_builder->buildTrack($track));
         }
         return $album;
     } catch (NotFoundException $e) {
         throw new AlbumNotFoundException();
     }
 }