Sulu\Bundle\MediaBundle\Controller\MediaController::getAction PHP Method

getAction() public method

Shows a single media with the given id.
public getAction ( $id, Request $request ) : Response
$id
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\Response
    public function getAction($id, Request $request)
    {
        try {
            $locale = $this->getRequestParameter($request, 'locale', true);
            $mediaManager = $this->getMediaManager();
            $view = $this->responseGetById($id, function ($id) use($locale, $mediaManager) {
                $media = $mediaManager->getById($id, $locale);
                $collection = $media->getEntity()->getCollection();
                if ($collection->getType()->getKey() === SystemCollectionManagerInterface::COLLECTION_TYPE) {
                    $this->getSecurityChecker()->checkPermission('sulu.media.system_collections', PermissionTypes::VIEW);
                }
                return $media;
            });
        } catch (MediaNotFoundException $e) {
            $view = $this->view($e->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }
        return $this->handleView($view);
    }