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

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

            $fieldDescriptors = $this->getFieldDescriptors();
            $listBuilder = $this->generateFlatListBuilder();
            $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
            $this->applyRequestParameters($request, $listBuilder);

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

            $list = new ListRepresentation(
                $listResponse,
                self::$entityKey,
                'get_accounts',
                $request->query->all(),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
            $view = $this->view($list, 200);
        } else {
            $filter = $this->retrieveFilter($request);
            $accountManager = $this->getAccountManager();
            $accounts = $accountManager->findAll($locale, $filter);
            $list = new CollectionRepresentation($accounts, self::$entityKey);
            $view = $this->view($list, 200);
        }

        $context = new Context();
        $context->setGroups(['fullAccount', 'partialContact', 'Default']);
        $view->setContext($context);

        return $this->handleView($view);
    }
public function cgetAction(Request $request)
    {
        $locale = $this->getUser()->getLocale();

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

            $fieldDescriptors = $this->getFieldDescriptors();
            $listBuilder = $this->generateFlatListBuilder();
            $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
            $this->applyRequestParameters($request, $listBuilder);

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

            $list = new ListRepresentation(
                $listResponse,
                self::$entityKey,
                'get_accounts',
                $request->query->all(),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
            $view = $this->view($list, 200);
        } else {
            $filter = $this->retrieveFilter($request);
            $accountManager = $this->getAccountManager();
            $accounts = $accountManager->findAll($locale, $filter);
            $list = new CollectionRepresentation($accounts, self::$entityKey);
            $view = $this->view($list, 200);
        }

        $context = new Context();
        $context->setGroups(['fullAccount', 'partialContact', 'Default']);
        $view->setContext($context);

        return $this->handleView($view);
    }
public function cgetAction ( Request $ request ) { $ locale = $ this -> getUser ( ) -> getLocale ( ) ; if ( 'true' == $ request -> get ( 'flat' ) ) { /** @var RestHelperInterface $restHelper */ $ restHelper = $ this -> get ( 'sulu_core.doctrine_rest_helper' ) ; $ fieldDescriptors = $ this -> getFieldDescriptors ( ) ; $ listBuilder = $ this -> generateFlatListBuilder ( ) ; $ restHelper -> initializeListBuilder ( $ listBuilder , $ fieldDescriptors ) ; $ this -> applyRequestParameters ( $ request , $ listBuilder ) ; $ listResponse = $ listBuilder -> execute ( ) ; $ listResponse = $ this -> addLogos ( $ listResponse , $ locale ) ; $ list = new ListRepresentation ( $ listResponse , self :: $ entityKey , 'get_accounts' , $ request -> query -> all ( ) , $ listBuilder -> getCurrentPage ( ) , $ listBuilder -> getLimit ( ) , $ listBuilder -> count ( ) ) ; $ view = $ this -> view ( $ list , 200 ) ; } else { $ filter = $ this -> retrieveFilter ( $ request ) ; $ accountManager = $ this -> getAccountManager ( ) ; $ accounts = $ accountManager -> findAll ( $ locale , $ filter ) ; $ list = new CollectionRepresentation ( $ accounts , self :: $ entityKey ) ; $ view = $ this -> view ( $ list , 200 ) ; } $ context = new Context ( ) ; $ context -> setGroups ( [ 'fullAccount' , 'partialContact' , 'Default' ] ) ; $ view -> setContext ( $ context ) ; return $ this -> handleView ( $ view ) ; }
Lists all accounts.
Optional parameter 'flat' calls listAction.

@param Request $request

@return Response
Lists all accounts . Optional parameter flat calls listAction .