/**
* @param Media $media
*
* @return array
*
* @throws \Sulu\Bundle\MediaBundle\Media\Exception\ImageProxyMediaNotFoundException
*/
protected function getMediaData($media)
{
$fileName = null;
$storageOptions = null;
$version = null;
$mimeType = null;
/** @var File $file */
foreach ($media->getFiles() as $file) {
$version = $file->getVersion();
/** @var FileVersion $fileVersion */
foreach ($file->getFileVersions() as $fileVersion) {
if ($fileVersion->getVersion() == $version) {
$fileName = $fileVersion->getName();
$storageOptions = $fileVersion->getStorageOptions();
$mimeType = $fileVersion->getMimeType();
break;
}
}
break;
}
if (!$fileName) {
throw new ImageProxyMediaNotFoundException('Media file version was not found');
}
return [$fileName, $version, $storageOptions, $mimeType];
}