src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
public function cgetAction(Request $request)
    {
        $locale = $this->getLocale($request);

        // if the type parameter is falsy, assign NULL to $type
        $type = $request->query->get('type', null) ?: null;

        $idsString = $request->get('ids');

        if ($idsString) {
            $ids = explode(',', $idsString);
            $snippets = $this->snippetRepository->getSnippetsByUuids($ids, $locale);
            $total = count($snippets);
        } else {
            $snippets = $this->snippetRepository->getSnippets(
                $locale,
                $type,
                $this->listRestHelper->getOffset(),
                $this->listRestHelper->getLimit(),
                $this->listRestHelper->getSearchPattern(),
                $this->listRestHelper->getSortColumn(),
                $this->listRestHelper->getSortOrder()
            );

            $total = $this->snippetRepository->getSnippetsAmount(
                $locale,
                $type,
                $this->listRestHelper->getSearchPattern(),
                $this->listRestHelper->getSortColumn(),
                $this->listRestHelper->getSortOrder()
            );
        }

        $data = new ListRepresentation(
            $snippets,
            'snippets',
            'get_snippets',
            $request->query->all(),
            $this->listRestHelper->getPage(),
            $this->listRestHelper->getLimit(),
            $total
        );

        return $this->viewHandler->handle(View::create($data));
    }
public function cgetAction(Request $request)
    {
        $locale = $this->getLocale($request);

        // if the type parameter is falsy, assign NULL to $type
        $type = $request->query->get('type', null) ?: null;

        $idsString = $request->get('ids');

        if ($idsString) {
            $ids = explode(',', $idsString);
            $snippets = $this->snippetRepository->getSnippetsByUuids($ids, $locale);
            $total = count($snippets);
        } else {
            $snippets = $this->snippetRepository->getSnippets(
                $locale,
                $type,
                $this->listRestHelper->getOffset(),
                $this->listRestHelper->getLimit(),
                $this->listRestHelper->getSearchPattern(),
                $this->listRestHelper->getSortColumn(),
                $this->listRestHelper->getSortOrder()
            );

            $total = $this->snippetRepository->getSnippetsAmount(
                $locale,
                $type,
                $this->listRestHelper->getSearchPattern(),
                $this->listRestHelper->getSortColumn(),
                $this->listRestHelper->getSortOrder()
            );
        }

        $data = new ListRepresentation(
            $snippets,
            'snippets',
            'get_snippets',
            $request->query->all(),
            $this->listRestHelper->getPage(),
            $this->listRestHelper->getLimit(),
            $total
        );

        return $this->viewHandler->handle(View::create($data));
    }
public function cgetAction ( Request $ request ) { $ locale = $ this -> getLocale ( $ request ) ; // if the type parameter is falsy, assign NULL to $type $ type = $ request -> query -> get ( 'type' , null ) ? : null ; $ idsString = $ request -> get ( 'ids' ) ; if ( $ idsString ) { $ ids = explode ( ',' , $ idsString ) ; $ snippets = $ this -> snippetRepository -> getSnippetsByUuids ( $ ids , $ locale ) ; $ total = count ( $ snippets ) ; } else { $ snippets = $ this -> snippetRepository -> getSnippets ( $ locale , $ type , $ this -> listRestHelper -> getOffset ( ) , $ this -> listRestHelper -> getLimit ( ) , $ this -> listRestHelper -> getSearchPattern ( ) , $ this -> listRestHelper -> getSortColumn ( ) , $ this -> listRestHelper -> getSortOrder ( ) ) ; $ total = $ this -> snippetRepository -> getSnippetsAmount ( $ locale , $ type , $ this -> listRestHelper -> getSearchPattern ( ) , $ this -> listRestHelper -> getSortColumn ( ) , $ this -> listRestHelper -> getSortOrder ( ) ) ; } $ data = new ListRepresentation ( $ snippets , 'snippets' , 'get_snippets' , $ request -> query -> all ( ) , $ this -> listRestHelper -> getPage ( ) , $ this -> listRestHelper -> getLimit ( ) , $ total ) ; return $ this -> viewHandler -> handle ( View :: create ( $ data ) ) ; }
Returns list of snippets.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response
Returns list of snippets .