/** * Loads the users of the group with the given path * * @param $groupPath * * @return \eZ\Publish\Core\REST\Server\Values\UserList|\eZ\Publish\Core\REST\Server\Values\UserRefList */ public function loadUsersFromGroup($groupPath) { $userGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($groupPath)); $userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId); $offset = $this->request->query->has('offset') ? (int) $this->request->query->get('offset') : 0; $limit = $this->request->query->has('limit') ? (int) $this->request->query->get('limit') : -1; $users = $this->userService->loadUsersOfUserGroup($userGroup, $offset >= 0 ? $offset : 0, $limit >= 0 ? $limit : -1); $restUsers = array(); foreach ($users as $user) { $userContentInfo = $user->getVersionInfo()->getContentInfo(); $userLocation = $this->locationService->loadLocation($userContentInfo->mainLocationId); $contentType = $this->contentTypeService->loadContentType($userContentInfo->contentTypeId); $restUsers[] = new Values\RestUser($user, $contentType, $userContentInfo, $userLocation, $this->contentService->loadRelations($user->getVersionInfo())); } if ($this->getMediaType() === 'application/vnd.ez.api.userlist') { return new Values\CachedValue(new Values\UserList($restUsers, $this->request->getPathInfo()), array('locationId' => $userGroupLocation->id)); } return new Values\CachedValue(new Values\UserRefList($restUsers, $this->request->getPathInfo()), array('locationId' => $userGroupLocation->id)); }
/** * Loads the users of a user group * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the users or user group * * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup * @param int $offset * @param int $limit * * @return \eZ\Publish\API\Repository\Values\User\User[] */ public function loadUsersOfUserGroup(UserGroup $userGroup, $offset = 0, $limit = -1) { return $this->service->loadUsersOfUserGroup($userGroup, $offset, $limit); }