/**
  * @param MediaInterface $media
  *
  * @return string
  */
 public function getMediaUrl(MediaInterface $media = null)
 {
     if (!$media) {
         return false;
     }
     $mediaDir = $this->options['uploader']['media_path'];
     return sprintf('/%s/%s', $mediaDir, $media->getFilename());
 }
 /**
  * @param MediaInterface $entity
  * @param bool $withFlush
  * @throws \RuntimeException
  */
 public function delete(MediaInterface $entity, $withFlush = false)
 {
     if (!unlink($entity->getPath() . '/' . $entity->getFileName())) {
         throw new \RuntimeException('Cannot delete file');
     }
     $this->eventDispatcher->dispatch(MediaEvents::DELETE_MEDIA, new MediaEvent($entity));
     $this->entityManager->remove($entity);
     if ($withFlush) {
         $this->entityManager->flush();
     }
 }