src/Sulu/Bundle/MediaBundle/Controller/MediaRedirectController.php
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]);
    }
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]);
    }
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 ] ) ; }
Redirects to format or original url.

@param Request $request
@param int $id

@return RedirectResponse
Redirects to format or original url .