public function redirectAction(Request $request, $id)
{
$locale = $this->getRequestParameter($request, 'locale', true);
$format = $this->getRequestParameter($request, 'format');
/** @var Media $media */
$media = $this->container->get('sulu_media.media_manager')->getById($id, $locale);
if (null === $format) {
return $this->redirect($media->getUrl());
}
if (!array_key_exists($format, $media->getFormats())) {
throw $this->createNotFoundException();
}
return $this->redirect($media->getFormats()[$format]);
}