src/Sulu/Bundle/SecurityBundle/Controller/UserController.php
public function cgetAction(Request $request)
    {
        $view = null;
        if ('true' == $request->get('flat')) {
            /** @var RestHelperInterface $restHelper */
            $restHelper = $this->get('sulu_core.doctrine_rest_helper');

            /** @var DoctrineListBuilderFactory $factory */
            $factory = $this->get('sulu_core.doctrine_list_builder_factory');

            $listBuilder = $factory->create($this->container->getParameter('sulu.model.user.class'));

            $restHelper->initializeListBuilder($listBuilder, $this->getFieldDescriptors());

            $list = new ListRepresentation(
                $listBuilder->execute(),
                static::$entityKey,
                'get_users',
                $request->query->all(),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
        } else {
            $contactId = $request->get('contactId');

            if (null != $contactId) {
                $user = $this->getDoctrine()->getRepository(
                    $this->container->getParameter('sulu.model.user.class')
                )->findUserByContact($contactId);

                $view = $this->view($user ?? new \stdClass(), 200);
            } else {
                $entities = $this->getUserManager()->findAll();
                $list = new CollectionRepresentation($entities, static::$entityKey);
            }
        }

        if (!$view) {
            $view = $this->view($list, 200);
        }

        $this->addSerializationGroups($view);

        return $this->handleView($view);
    }
public function cgetAction(Request $request)
    {
        $view = null;
        if ('true' == $request->get('flat')) {
            /** @var RestHelperInterface $restHelper */
            $restHelper = $this->get('sulu_core.doctrine_rest_helper');

            /** @var DoctrineListBuilderFactory $factory */
            $factory = $this->get('sulu_core.doctrine_list_builder_factory');

            $listBuilder = $factory->create($this->container->getParameter('sulu.model.user.class'));

            $restHelper->initializeListBuilder($listBuilder, $this->getFieldDescriptors());

            $list = new ListRepresentation(
                $listBuilder->execute(),
                static::$entityKey,
                'get_users',
                $request->query->all(),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
        } else {
            $contactId = $request->get('contactId');

            if (null != $contactId) {
                $user = $this->getDoctrine()->getRepository(
                    $this->container->getParameter('sulu.model.user.class')
                )->findUserByContact($contactId);

                $view = $this->view($user ?? new \stdClass(), 200);
            } else {
                $entities = $this->getUserManager()->findAll();
                $list = new CollectionRepresentation($entities, static::$entityKey);
            }
        }

        if (!$view) {
            $view = $this->view($list, 200);
        }

        $this->addSerializationGroups($view);

        return $this->handleView($view);
    }
public function cgetAction ( Request $ request ) { $ view = null ; if ( 'true' == $ request -> get ( 'flat' ) ) { /** @var RestHelperInterface $restHelper */ $ restHelper = $ this -> get ( 'sulu_core.doctrine_rest_helper' ) ; /** @var DoctrineListBuilderFactory $factory */ $ factory = $ this -> get ( 'sulu_core.doctrine_list_builder_factory' ) ; $ listBuilder = $ factory -> create ( $ this -> container -> getParameter ( 'sulu.model.user.class' ) ) ; $ restHelper -> initializeListBuilder ( $ listBuilder , $ this -> getFieldDescriptors ( ) ) ; $ list = new ListRepresentation ( $ listBuilder -> execute ( ) , static :: $ entityKey , 'get_users' , $ request -> query -> all ( ) , $ listBuilder -> getCurrentPage ( ) , $ listBuilder -> getLimit ( ) , $ listBuilder -> count ( ) ) ; } else { $ contactId = $ request -> get ( 'contactId' ) ; if ( null != $ contactId ) { $ user = $ this -> getDoctrine ( ) -> getRepository ( $ this -> container -> getParameter ( 'sulu.model.user.class' ) ) -> findUserByContact ( $ contactId ) ; $ view = $ this -> view ( $ user ?? new \ stdClass ( ) , 200 ) ; } else { $ entities = $ this -> getUserManager ( ) -> findAll ( ) ; $ list = new CollectionRepresentation ( $ entities , static :: $ entityKey ) ; } } if ( ! $ view ) { $ view = $ this -> view ( $ list , 200 ) ; } $ this -> addSerializationGroups ( $ view ) ; return $ this -> handleView ( $ view ) ; }
Returns a user with a specific contact id or all users
optional parameter 'flat' calls listAction.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response
Returns a user with a specific contact id or all users optional parameter flat calls listAction .