public function build($project_id, $is_used_by_default, array $ugroups) { $ugroup_representations = array(); foreach ($ugroups as $user_group) { $ugroup_representation = new UserGroupRepresentation(); $ugroup_representation->build($project_id, $user_group); $ugroup_representations[] = $ugroup_representation; } $this->is_used_by_default = $is_used_by_default; $this->ugroup_representations = $ugroup_representations; }
private function buildUGroupRepresentations(GitRepository $repository, $ugroup_rows) { $ugroup_representations = array(); foreach ($ugroup_rows as $row) { $ugroup = $this->ugroup_manager->getById($row['ugroup_id']); $rewind_ugroup_representation = new UserGroupRepresentation(); $rewind_ugroup_representation->build($repository->getProjectId(), $ugroup); $ugroup_representations[] = $rewind_ugroup_representation; } return $ugroup_representations; }
/** * Get a user_group * * Get the definition of a given user_group * * @url GET {id} * @access protected * * @param string $id Id of the ugroup (format: projectId_ugroupId) * * @throws 400 * @throws 403 * @throws 404 * * @return \Tuleap\Project\REST\UserGroupRepresentation */ protected function getId($id) { $this->checkIdIsWellFormed($id); list($project_id, $ugroup_id) = explode('_', $id); $this->isGroupViewable($ugroup_id); $this->checkUserGroupIdExists($ugroup_id); $this->userCanSeeUserGroups($project_id); $ugroup = $this->ugroup_manager->getById($ugroup_id); $ugroup_representation = new UserGroupRepresentation(); $ugroup_representation->build($project_id, $ugroup); $this->sendAllowHeadersForUserGroup(); return $ugroup_representation; }
/** * Checks if the given user group exists * * @param int $id * * @return ProjectUGroup * * @throws 404 */ private function getExistingUserGroup($id) { $this->checkIdIsAppropriate($id); $values = UserGroupRepresentation::getProjectAndUserGroupFromRESTId($id); $user_group_id = $values['user_group_id']; $user_group = $this->ugroup_manager->getById($user_group_id); if ($user_group->getId() === 0) { throw new RestException(404, 'User Group does not exist'); } if (!$user_group->isStatic()) { $user_group->setProjectId($values['project_id']); } if ($user_group->isStatic() && $values['project_id'] && $values['project_id'] != $user_group->getProjectId()) { throw new RestException(404, 'User Group does not exist in project'); } return $user_group; }
private function getUserGroupsRepresentations(array $ugroups, $project_id) { $user_groups = array(); foreach ($ugroups as $ugroup) { $representation = new UserGroupRepresentation(); $representation->build($project_id, $ugroup); $user_groups[] = $representation; } return $user_groups; }