src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php
public function cgetAction(Request $request)
    {
        try {
            /** @var ListRestHelperInterface $listRestHelper */
            $listRestHelper = $this->get('sulu_core.list_rest_helper');
            $securityChecker = $this->get('sulu_security.security_checker');

            $flat = $this->getBooleanRequestParameter($request, 'flat', false);
            $depth = $request->get('depth', 0);
            $parentId = $request->get('parentId', null);
            $limit = $request->get('limit', null);
            $offset = $this->getOffset($request, $limit);
            $search = $listRestHelper->getSearchPattern();
            $sortBy = $request->get('sortBy');
            $sortOrder = $request->get('sortOrder', 'ASC');
            $includeRoot = $this->getBooleanRequestParameter($request, 'includeRoot', false, false);
            $collectionManager = $this->getCollectionManager();

            if ('root' === $parentId) {
                $includeRoot = false;
                $parentId = null;
            }

            if ($flat) {
                $collections = $collectionManager->get(
                    $this->getRequestParameter($request, 'locale', true),
                    [
                        'depth' => $depth,
                        'parent' => $parentId,
                    ],
                    $limit,
                    $offset,
                    null !== $sortBy ? [$sortBy => $sortOrder] : []
                );
            } else {
                $collections = $collectionManager->getTree(
                    $this->getRequestParameter($request, 'locale', true),
                    $offset,
                    $limit,
                    $search,
                    $depth,
                    null !== $sortBy ? [$sortBy => $sortOrder] : [],
                    $securityChecker->hasPermission('sulu.media.system_collections', 'view')
                );
            }

            if ($includeRoot && !$parentId) {
                $collections = [
                    new RootCollection(
                        $this->get('translator')->trans('sulu_media.all_collections', [], 'admin'),
                        $collections
                    ),
                ];
            }

            $all = $collectionManager->getCount();

            $list = new ListRepresentation(
                $collections,
                self::$entityKey,
                'get_collections',
                $request->query->all(),
                $listRestHelper->getPage(),
                $listRestHelper->getLimit(),
                $all
            );

            $view = $this->view($list, 200);
        } catch (CollectionNotFoundException $cnf) {
            $view = $this->view($cnf->toArray(), 404);
        } catch (MediaException $me) {
            $view = $this->view($me->toArray(), 400);
        }

        return $this->handleView($view);
    }
public function cgetAction(Request $request)
    {
        try {
            /** @var ListRestHelperInterface $listRestHelper */
            $listRestHelper = $this->get('sulu_core.list_rest_helper');
            $securityChecker = $this->get('sulu_security.security_checker');

            $flat = $this->getBooleanRequestParameter($request, 'flat', false);
            $depth = $request->get('depth', 0);
            $parentId = $request->get('parentId', null);
            $limit = $request->get('limit', null);
            $offset = $this->getOffset($request, $limit);
            $search = $listRestHelper->getSearchPattern();
            $sortBy = $request->get('sortBy');
            $sortOrder = $request->get('sortOrder', 'ASC');
            $includeRoot = $this->getBooleanRequestParameter($request, 'includeRoot', false, false);
            $collectionManager = $this->getCollectionManager();

            if ('root' === $parentId) {
                $includeRoot = false;
                $parentId = null;
            }

            if ($flat) {
                $collections = $collectionManager->get(
                    $this->getRequestParameter($request, 'locale', true),
                    [
                        'depth' => $depth,
                        'parent' => $parentId,
                    ],
                    $limit,
                    $offset,
                    null !== $sortBy ? [$sortBy => $sortOrder] : []
                );
            } else {
                $collections = $collectionManager->getTree(
                    $this->getRequestParameter($request, 'locale', true),
                    $offset,
                    $limit,
                    $search,
                    $depth,
                    null !== $sortBy ? [$sortBy => $sortOrder] : [],
                    $securityChecker->hasPermission('sulu.media.system_collections', 'view')
                );
            }

            if ($includeRoot && !$parentId) {
                $collections = [
                    new RootCollection(
                        $this->get('translator')->trans('sulu_media.all_collections', [], 'admin'),
                        $collections
                    ),
                ];
            }

            $all = $collectionManager->getCount();

            $list = new ListRepresentation(
                $collections,
                self::$entityKey,
                'get_collections',
                $request->query->all(),
                $listRestHelper->getPage(),
                $listRestHelper->getLimit(),
                $all
            );

            $view = $this->view($list, 200);
        } catch (CollectionNotFoundException $cnf) {
            $view = $this->view($cnf->toArray(), 404);
        } catch (MediaException $me) {
            $view = $this->view($me->toArray(), 400);
        }

        return $this->handleView($view);
    }
public function cgetAction ( Request $ request ) { try { /** @var ListRestHelperInterface $listRestHelper */ $ listRestHelper = $ this -> get ( 'sulu_core.list_rest_helper' ) ; $ securityChecker = $ this -> get ( 'sulu_security.security_checker' ) ; $ flat = $ this -> getBooleanRequestParameter ( $ request , 'flat' , false ) ; $ depth = $ request -> get ( 'depth' , 0 ) ; $ parentId = $ request -> get ( 'parentId' , null ) ; $ limit = $ request -> get ( 'limit' , null ) ; $ offset = $ this -> getOffset ( $ request , $ limit ) ; $ search = $ listRestHelper -> getSearchPattern ( ) ; $ sortBy = $ request -> get ( 'sortBy' ) ; $ sortOrder = $ request -> get ( 'sortOrder' , 'ASC' ) ; $ includeRoot = $ this -> getBooleanRequestParameter ( $ request , 'includeRoot' , false , false ) ; $ collectionManager = $ this -> getCollectionManager ( ) ; if ( 'root' === $ parentId ) { $ includeRoot = false ; $ parentId = null ; } if ( $ flat ) { $ collections = $ collectionManager -> get ( $ this -> getRequestParameter ( $ request , 'locale' , true ) , [ 'depth' => $ depth , 'parent' => $ parentId , ] , $ limit , $ offset , null !== $ sortBy ? [ $ sortBy => $ sortOrder ] : [ ] ) ; } else { $ collections = $ collectionManager -> getTree ( $ this -> getRequestParameter ( $ request , 'locale' , true ) , $ offset , $ limit , $ search , $ depth , null !== $ sortBy ? [ $ sortBy => $ sortOrder ] : [ ] , $ securityChecker -> hasPermission ( 'sulu.media.system_collections' , 'view' ) ) ; } if ( $ includeRoot && ! $ parentId ) { $ collections = [ new RootCollection ( $ this -> get ( 'translator' ) -> trans ( 'sulu_media.all_collections' , [ ] , 'admin' ) , $ collections ) , ] ; } $ all = $ collectionManager -> getCount ( ) ; $ list = new ListRepresentation ( $ collections , self :: $ entityKey , 'get_collections' , $ request -> query -> all ( ) , $ listRestHelper -> getPage ( ) , $ listRestHelper -> getLimit ( ) , $ all ) ; $ view = $ this -> view ( $ list , 200 ) ; } catch ( CollectionNotFoundException $ cnf ) { $ view = $ this -> view ( $ cnf -> toArray ( ) , 404 ) ; } catch ( MediaException $ me ) { $ view = $ this -> view ( $ me -> toArray ( ) , 400 ) ; } return $ this -> handleView ( $ view ) ; }
lists all collections.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response
lists all collections .