src/Sulu/Bundle/ContactBundle/Controller/AbstractMediaController.php
protected function getMultipleView($entityName, $routeName, AbstractContactManager $contactManager, $id, $request)
    {
        try {
            $locale = $this->getUser()->getLocale();

            if ('true' === $request->get('flat')) {
                /** @var RestHelperInterface $restHelper */
                $restHelper = $this->get('sulu_core.doctrine_rest_helper');

                /** @var DoctrineListBuilderFactory $factory */
                $factory = $this->get('sulu_core.doctrine_list_builder_factory');

                $listBuilder = $factory->create($entityName);
                $fieldDescriptors = $this->getFieldDescriptors($entityName, $id);
                $listBuilder->setIdField($fieldDescriptors['id']);
                $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);

                $listResponse = $listBuilder->execute();
                $listResponse = $this->addThumbnails($listResponse, $locale);
                $listResponse = $this->addUrls($listResponse, $locale);

                $list = new ListRepresentation(
                    $listResponse,
                    self::$mediaEntityKey,
                    $routeName,
                    array_merge(['id' => $id], $request->query->all()),
                    $listBuilder->getCurrentPage(),
                    $listBuilder->getLimit(),
                    $listBuilder->count()
                );
            } else {
                $media = $contactManager->getById($id, $locale)->getMedias();
                $list = new CollectionRepresentation($media, self::$mediaEntityKey);
            }
            $view = $this->view($list, 200);
        } catch (EntityNotFoundException $e) {
            $view = $this->view($e->toArray(), 404);
        }

        return $this->handleView($view);
    }
protected function getMultipleView($entityName, $routeName, AbstractContactManager $contactManager, $id, $request)
    {
        try {
            $locale = $this->getUser()->getLocale();

            if ('true' === $request->get('flat')) {
                /** @var RestHelperInterface $restHelper */
                $restHelper = $this->get('sulu_core.doctrine_rest_helper');

                /** @var DoctrineListBuilderFactory $factory */
                $factory = $this->get('sulu_core.doctrine_list_builder_factory');

                $listBuilder = $factory->create($entityName);
                $fieldDescriptors = $this->getFieldDescriptors($entityName, $id);
                $listBuilder->setIdField($fieldDescriptors['id']);
                $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);

                $listResponse = $listBuilder->execute();
                $listResponse = $this->addThumbnails($listResponse, $locale);
                $listResponse = $this->addUrls($listResponse, $locale);

                $list = new ListRepresentation(
                    $listResponse,
                    self::$mediaEntityKey,
                    $routeName,
                    array_merge(['id' => $id], $request->query->all()),
                    $listBuilder->getCurrentPage(),
                    $listBuilder->getLimit(),
                    $listBuilder->count()
                );
            } else {
                $media = $contactManager->getById($id, $locale)->getMedias();
                $list = new CollectionRepresentation($media, self::$mediaEntityKey);
            }
            $view = $this->view($list, 200);
        } catch (EntityNotFoundException $e) {
            $view = $this->view($e->toArray(), 404);
        }

        return $this->handleView($view);
    }
protected function getMultipleView ( $ entityName , $ routeName , AbstractContactManager $ contactManager , $ id , $ request ) { try { $ locale = $ this -> getUser ( ) -> getLocale ( ) ; if ( 'true' === $ request -> get ( 'flat' ) ) { /** @var RestHelperInterface $restHelper */ $ restHelper = $ this -> get ( 'sulu_core.doctrine_rest_helper' ) ; /** @var DoctrineListBuilderFactory $factory */ $ factory = $ this -> get ( 'sulu_core.doctrine_list_builder_factory' ) ; $ listBuilder = $ factory -> create ( $ entityName ) ; $ fieldDescriptors = $ this -> getFieldDescriptors ( $ entityName , $ id ) ; $ listBuilder -> setIdField ( $ fieldDescriptors [ 'id' ] ) ; $ restHelper -> initializeListBuilder ( $ listBuilder , $ fieldDescriptors ) ; $ listResponse = $ listBuilder -> execute ( ) ; $ listResponse = $ this -> addThumbnails ( $ listResponse , $ locale ) ; $ listResponse = $ this -> addUrls ( $ listResponse , $ locale ) ; $ list = new ListRepresentation ( $ listResponse , self :: $ mediaEntityKey , $ routeName , array_merge ( [ 'id' => $ id ] , $ request -> query -> all ( ) ) , $ listBuilder -> getCurrentPage ( ) , $ listBuilder -> getLimit ( ) , $ listBuilder -> count ( ) ) ; } else { $ media = $ contactManager -> getById ( $ id , $ locale ) -> getMedias ( ) ; $ list = new CollectionRepresentation ( $ media , self :: $ mediaEntityKey ) ; } $ view = $ this -> view ( $ list , 200 ) ; } catch ( EntityNotFoundException $ e ) { $ view = $ this -> view ( $ e -> toArray ( ) , 404 ) ; } return $ this -> handleView ( $ view ) ; }
Returns a view containing all media of an entity.

@param string $entityName
@param string $routeName
@param AbstractContactManager $contactManager
@param string $id
@param Request $request

@return Response
Returns a view containing all media of an entity .