/** * Get the album videos * * @param int $albumId * @param string $sorting * @param string $direction * * @return array|null */ public function getAlbumVideos($albumId, $sorting = null, $direction = null) { $albumId = (int) $albumId; $cacheKey = 'album_videos_' . $albumId . ($sorting ? '_' . $sorting : '') . ($direction ? '_' . $direction : ''); if ($this->cache->isDataObsolete($cacheKey)) { if (($albumVideosData = $this->fetchAlbumVideos($albumId, $sorting, $direction)) === null) { return null; } // Update the video data by the way foreach ($albumVideosData as $video) { $videoId = $this->extractVideoId($video); $this->cache->setData('video_' . $videoId, $video); // Also set album by video data if (($albumData = $this->getAlbum($albumId)) !== null) { $this->cache->setReference('album_video_' . $videoId, 'album_' . $this->extractAlbumId($albumData)); } } $this->cache->setData($cacheKey, $albumVideosData); } return parent::getAlbumVideos($albumId, $sorting, $direction); }