/**
* {@inheritdoc}
*/
public function delete($mediaId, $formatKey)
{
if (!isset($this->formats[$formatKey])) {
throw new FormatNotFoundException($formatKey);
}
$media = $this->mediaManager->getEntityById($mediaId);
$fileVersion = $this->getFileVersionForMedia($media);
$formatOptions = $fileVersion->getFormatOptions()->get($formatKey);
if (isset($formatOptions)) {
$fileVersion->getFormatOptions()->remove($formatKey);
$fileVersion->increaseSubVersion();
$this->em->remove($formatOptions);
$this->em->persist($fileVersion);
$this->purgeMedia($mediaId, $fileVersion);
}
}