public function loadUserGroupsOfUser($userId, Request $request)
    {
        $offset = $request->query->has('offset') ? (int)$request->query->get('offset') : 0;
        $limit = $request->query->has('limit') ? (int)$request->query->get('limit') : 25;

        $user = $this->userService->loadUser($userId);
        $userGroups = $this->userService->loadUserGroupsOfUser(
            $user,
            $offset >= 0 ? $offset : 0,
            $limit >= 0 ? $limit : 25,
            Language::ALL
        );

        $restUserGroups = array();
        foreach ($userGroups as $userGroup) {
            $userGroupContentInfo = $userGroup->getVersionInfo()->getContentInfo();
            $userGroupLocation = $this->locationService->loadLocation($userGroupContentInfo->mainLocationId);
            $contentType = $this->contentTypeService->loadContentType($userGroupContentInfo->contentTypeId);

            $restUserGroups[] = new Values\RestUserGroup(
                $userGroup,
                $contentType,
                $userGroupContentInfo,
                $userGroupLocation,
                $this->contentService->loadRelations($userGroup->getVersionInfo())
            );
        }

        return new Values\CachedValue(
            new Values\UserGroupRefList($restUserGroups, $request->getPathInfo(), $userId),
            array('locationId' => $user->contentInfo->mainLocationId)
        );
    }
public function loadUserGroupsOfUser($userId, Request $request)
    {
        $offset = $request->query->has('offset') ? (int)$request->query->get('offset') : 0;
        $limit = $request->query->has('limit') ? (int)$request->query->get('limit') : 25;

        $user = $this->userService->loadUser($userId);
        $userGroups = $this->userService->loadUserGroupsOfUser(
            $user,
            $offset >= 0 ? $offset : 0,
            $limit >= 0 ? $limit : 25,
            Language::ALL
        );

        $restUserGroups = array();
        foreach ($userGroups as $userGroup) {
            $userGroupContentInfo = $userGroup->getVersionInfo()->getContentInfo();
            $userGroupLocation = $this->locationService->loadLocation($userGroupContentInfo->mainLocationId);
            $contentType = $this->contentTypeService->loadContentType($userGroupContentInfo->contentTypeId);

            $restUserGroups[] = new Values\RestUserGroup(
                $userGroup,
                $contentType,
                $userGroupContentInfo,
                $userGroupLocation,
                $this->contentService->loadRelations($userGroup->getVersionInfo())
            );
        }

        return new Values\CachedValue(
            new Values\UserGroupRefList($restUserGroups, $request->getPathInfo(), $userId),
            array('locationId' => $user->contentInfo->mainLocationId)
        );
    }
public function loadUserGroupsOfUser ( $ userId , Request $ request ) { $ offset = $ request -> query -> has ( 'offset' ) ? ( int ) $ request -> query -> get ( 'offset' ) : 0 ; $ limit = $ request -> query -> has ( 'limit' ) ? ( int ) $ request -> query -> get ( 'limit' ) : 25 ; $ user = $ this -> userService -> loadUser ( $ userId ) ; $ userGroups = $ this -> userService -> loadUserGroupsOfUser ( $ user , $ offset >= 0 ? $ offset : 0 , $ limit >= 0 ? $ limit : 25 , Language :: ALL ) ; $ restUserGroups = array ( ) ; foreach ( $ userGroups as $ userGroup ) { $ userGroupContentInfo = $ userGroup -> getVersionInfo ( ) -> getContentInfo ( ) ; $ userGroupLocation = $ this -> locationService -> loadLocation ( $ userGroupContentInfo -> mainLocationId ) ; $ contentType = $ this -> contentTypeService -> loadContentType ( $ userGroupContentInfo -> contentTypeId ) ; $ restUserGroups [ ] = new Values \ RestUserGroup ( $ userGroup , $ contentType , $ userGroupContentInfo , $ userGroupLocation , $ this -> contentService -> loadRelations ( $ userGroup -> getVersionInfo ( ) ) ) ; } return new Values \ CachedValue ( new Values \ UserGroupRefList ( $ restUserGroups , $ request -> getPathInfo ( ) , $ userId ) , array ( 'locationId' => $ user -> contentInfo -> mainLocationId ) ) ; }
Returns a list of user groups the user belongs to.
The returned list includes the resources for unassigning
a user group if the user is in multiple groups.

@param $userId

@return \eZ\Publish\Core\REST\Server\Values\UserGroupRefList
Returns a list of user groups the user belongs to . The returned list includes the resources for unassigning a user group if the user is in multiple groups .