Example #1
0
 public function get(ArtistIdentity $identity)
 {
     $key = PRE_KEY . $identity->getId();
     $artist = $this->redis->get($key);
     if (!$artist) {
         $artist = $this->repository->get($identity);
         $this->redis->set($key, $artist);
     }
     return $artist;
 }
Example #2
0
 /**
  * Retrieves the artist with the given identity.
  *
  * @param  ArtistIdentity $identity The identity of the artist to retrieve.
  * @return Domain\Entity\Artist
  * @throws Domain\Exception\ArtistNotFoundException If no artist has the requested identity.
  */
 public function get(ArtistIdentity $identity)
 {
     try {
         $artist_raw = $this->spotify_api->getArtist($identity->getId());
         $artist_albums = $this->spotify_api->getArtistAlbums($identity->getId());
         $artist = Artist::create($artist_raw->id, $artist_raw->name);
         foreach ($artist_albums->items as $album) {
             $artist->addAlbum(Album::create($album->id, $album->name));
         }
         return $artist;
     } catch (NotFoundException $e) {
         throw new ArtistNotFoundException();
     }
 }