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

        if ('true' == $request->get('flat')) {
            $list = $this->getList($request, $locale);
        } else {
            if (true == $request->get('bySystem')) {
                $contacts = $this->getContactsByUserSystem();
                $serializationGroups[] = 'select';
            } else {
                $contacts = $this->getDoctrine()->getRepository(
                    $this->container->getParameter('sulu.model.contact.class')
                )->findAll();
                $serializationGroups = array_merge(
                    $serializationGroups,
                    static::$contactSerializationGroups
                );
            }
            // convert to api-contacts
            $apiContacts = [];
            foreach ($contacts as $contact) {
                $apiContacts[] = $this->getContactManager()->getContact($contact, $locale);
            }

            $exclusion = null;
            if (count($serializationGroups) > 0) {
                $exclusion = new Exclusion($serializationGroups);
            }

            $list = new CollectionRepresentation($apiContacts, self::$entityKey, null, $exclusion, $exclusion);
        }

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

        // set serialization groups
        if (count($serializationGroups) > 0) {
            $context = new Context();
            $context->setGroups($serializationGroups);
            $view->setContext($context);
        }

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

        if ('true' == $request->get('flat')) {
            $list = $this->getList($request, $locale);
        } else {
            if (true == $request->get('bySystem')) {
                $contacts = $this->getContactsByUserSystem();
                $serializationGroups[] = 'select';
            } else {
                $contacts = $this->getDoctrine()->getRepository(
                    $this->container->getParameter('sulu.model.contact.class')
                )->findAll();
                $serializationGroups = array_merge(
                    $serializationGroups,
                    static::$contactSerializationGroups
                );
            }
            // convert to api-contacts
            $apiContacts = [];
            foreach ($contacts as $contact) {
                $apiContacts[] = $this->getContactManager()->getContact($contact, $locale);
            }

            $exclusion = null;
            if (count($serializationGroups) > 0) {
                $exclusion = new Exclusion($serializationGroups);
            }

            $list = new CollectionRepresentation($apiContacts, self::$entityKey, null, $exclusion, $exclusion);
        }

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

        // set serialization groups
        if (count($serializationGroups) > 0) {
            $context = new Context();
            $context->setGroups($serializationGroups);
            $view->setContext($context);
        }

        return $this->handleView($view);
    }
public function cgetAction ( Request $ request ) { $ serializationGroups = [ ] ; $ locale = $ this -> getLocale ( $ request ) ; if ( 'true' == $ request -> get ( 'flat' ) ) { $ list = $ this -> getList ( $ request , $ locale ) ; } else { if ( true == $ request -> get ( 'bySystem' ) ) { $ contacts = $ this -> getContactsByUserSystem ( ) ; $ serializationGroups [ ] = 'select' ; } else { $ contacts = $ this -> getDoctrine ( ) -> getRepository ( $ this -> container -> getParameter ( 'sulu.model.contact.class' ) ) -> findAll ( ) ; $ serializationGroups = array_merge ( $ serializationGroups , static :: $ contactSerializationGroups ) ; } // convert to api-contacts $ apiContacts = [ ] ; foreach ( $ contacts as $ contact ) { $ apiContacts [ ] = $ this -> getContactManager ( ) -> getContact ( $ contact , $ locale ) ; } $ exclusion = null ; if ( count ( $ serializationGroups ) > 0 ) { $ exclusion = new Exclusion ( $ serializationGroups ) ; } $ list = new CollectionRepresentation ( $ apiContacts , self :: $ entityKey , null , $ exclusion , $ exclusion ) ; } $ view = $ this -> view ( $ list , 200 ) ; // set serialization groups if ( count ( $ serializationGroups ) > 0 ) { $ context = new Context ( ) ; $ context -> setGroups ( $ serializationGroups ) ; $ view -> setContext ( $ context ) ; } return $ this -> handleView ( $ view ) ; }
lists all contacts
optional parameter 'flat' calls listAction.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response
lists all contacts optional parameter flat calls listAction .