コード例 #1
0
ファイル: Role.php プロジェクト: dfritschy/ezpublish-kernel
 /**
  * Returns a role assignment to the given user group
  *
  * @param $groupPath
  * @param $roleId
  *
  * @throws \eZ\Publish\Core\REST\Common\Exceptions\NotFoundException
  * @return \eZ\Publish\Core\REST\Server\Values\RestUserGroupRoleAssignment
  */
 public function loadRoleAssignmentForUserGroup($groupPath, $roleId)
 {
     $groupLocationParts = explode('/', $groupPath);
     $groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
     $userGroup = $this->userService->loadUserGroup($groupLocation->contentId);
     $roleAssignments = $this->roleService->getRoleAssignmentsForUserGroup($userGroup);
     foreach ($roleAssignments as $roleAssignment) {
         if ($roleAssignment->getRole()->id == $roleId) {
             return new Values\RestUserGroupRoleAssignment($roleAssignment, $groupPath);
         }
     }
     throw new Exceptions\NotFoundException("Role assignment not found: '{$this->request->getPathInfo()}'.");
 }
コード例 #2
0
 /**
  * Returns the roles assigned to the given user group.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read a user group
  *
  * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[]
  */
 public function getRoleAssignmentsForUserGroup(UserGroup $userGroup)
 {
     return $this->service->getRoleAssignmentsForUserGroup($userGroup);
 }