/** * Gets the latest file-version of a given media. * * @param MediaInterface $media * * @throws FileVersionNotFoundException * * @return FileVersion */ private function getFileVersionForMedia(MediaInterface $media) { /** @var File $file */ $file = $media->getFiles()->get(0); if (!isset($file)) { throw new FileVersionNotFoundException($media->getId(), 'latest'); } $fileVersion = $file->getLatestFileVersion(); if (!isset($fileVersion)) { throw new FileVersionNotFoundException($media->getId(), 'latest'); } return $fileVersion; }