src/Sulu/Bundle/MediaBundle/Controller/MediaController.php
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $fieldDescriptors = $this->getFieldDescriptors($locale, false);
        $types = array_filter(explode(',', $request->get('types')));
        $listBuilder = $this->getListBuilder($request, $fieldDescriptors, $types);
        $listBuilder->setParameter('locale', $locale);
        $listResponse = $listBuilder->execute();
        $count = $listBuilder->count();

        for ($i = 0, $length = count($listResponse); $i < $length; ++$i) {
            $format = $this->getFormatManager()->getFormats(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['storageOptions'],
                $listResponse[$i]['version'],
                $listResponse[$i]['subVersion'],
                $listResponse[$i]['mimeType']
            );

            if (0 < count($format)) {
                $listResponse[$i]['thumbnails'] = $format;
            }

            $listResponse[$i]['url'] = $this->getMediaManager()->getUrl(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['version']
            );
        }

        $ids = $listBuilder->getIds();
        if (null != $ids) {
            $result = [];
            foreach ($listResponse as $item) {
                $result[array_search($item['id'], $ids)] = $item;
            }
            ksort($result);
            $listResponse = array_values($result);
        }

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'cget_media',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $count
        );

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $fieldDescriptors = $this->getFieldDescriptors($locale, false);
        $types = array_filter(explode(',', $request->get('types')));
        $listBuilder = $this->getListBuilder($request, $fieldDescriptors, $types);
        $listBuilder->setParameter('locale', $locale);
        $listResponse = $listBuilder->execute();
        $count = $listBuilder->count();

        for ($i = 0, $length = count($listResponse); $i < $length; ++$i) {
            $format = $this->getFormatManager()->getFormats(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['storageOptions'],
                $listResponse[$i]['version'],
                $listResponse[$i]['subVersion'],
                $listResponse[$i]['mimeType']
            );

            if (0 < count($format)) {
                $listResponse[$i]['thumbnails'] = $format;
            }

            $listResponse[$i]['url'] = $this->getMediaManager()->getUrl(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['version']
            );
        }

        $ids = $listBuilder->getIds();
        if (null != $ids) {
            $result = [];
            foreach ($listResponse as $item) {
                $result[array_search($item['id'], $ids)] = $item;
            }
            ksort($result);
            $listResponse = array_values($result);
        }

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'cget_media',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $count
        );

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
public function cgetAction ( Request $ request ) { $ locale = $ this -> getRequestParameter ( $ request , 'locale' , true ) ; $ fieldDescriptors = $ this -> getFieldDescriptors ( $ locale , false ) ; $ types = array_filter ( explode ( ',' , $ request -> get ( 'types' ) ) ) ; $ listBuilder = $ this -> getListBuilder ( $ request , $ fieldDescriptors , $ types ) ; $ listBuilder -> setParameter ( 'locale' , $ locale ) ; $ listResponse = $ listBuilder -> execute ( ) ; $ count = $ listBuilder -> count ( ) ; for ( $ i = 0 , $ length = count ( $ listResponse ) ; $ i < $ length ; ++ $ i ) { $ format = $ this -> getFormatManager ( ) -> getFormats ( $ listResponse [ $ i ] [ 'id' ] , $ listResponse [ $ i ] [ 'name' ] , $ listResponse [ $ i ] [ 'storageOptions' ] , $ listResponse [ $ i ] [ 'version' ] , $ listResponse [ $ i ] [ 'subVersion' ] , $ listResponse [ $ i ] [ 'mimeType' ] ) ; if ( 0 < count ( $ format ) ) { $ listResponse [ $ i ] [ 'thumbnails' ] = $ format ; } $ listResponse [ $ i ] [ 'url' ] = $ this -> getMediaManager ( ) -> getUrl ( $ listResponse [ $ i ] [ 'id' ] , $ listResponse [ $ i ] [ 'name' ] , $ listResponse [ $ i ] [ 'version' ] ) ; } $ ids = $ listBuilder -> getIds ( ) ; if ( null != $ ids ) { $ result = [ ] ; foreach ( $ listResponse as $ item ) { $ result [ array_search ( $ item [ 'id' ] , $ ids ) ] = $ item ; } ksort ( $ result ) ; $ listResponse = array_values ( $ result ) ; } $ list = new ListRepresentation ( $ listResponse , self :: $ entityKey , 'cget_media' , $ request -> query -> all ( ) , $ listBuilder -> getCurrentPage ( ) , $ listBuilder -> getLimit ( ) , $ count ) ; $ view = $ this -> view ( $ list , 200 ) ; return $ this -> handleView ( $ view ) ; }
Lists all media.

@param Request $request

@return Response
Lists all media .