eZ\Publish\Core\Repository\RoleService::loadRoleAssignment PHP Method

loadRoleAssignment() public method

Loads a role assignment for the given id.
public loadRoleAssignment ( mixed $roleAssignmentId ) : eZ\Publish\API\Repository\Values\User\RoleAssignment
$roleAssignmentId mixed
return eZ\Publish\API\Repository\Values\User\RoleAssignment
    public function loadRoleAssignment($roleAssignmentId)
    {
        if ($this->repository->hasAccess('role', 'read') !== true) {
            throw new UnauthorizedException('role', 'read');
        }
        $spiRoleAssignment = $this->userHandler->loadRoleAssignment($roleAssignmentId);
        $userService = $this->repository->getUserService();
        $role = $this->loadRole($spiRoleAssignment->roleId);
        $roleAssignment = null;
        // First check if the Role is assigned to a User
        // If no User is found, see if it belongs to a UserGroup
        try {
            $user = $userService->loadUser($spiRoleAssignment->contentId);
            $roleAssignment = $this->roleDomainMapper->buildDomainUserRoleAssignmentObject($spiRoleAssignment, $user, $role);
        } catch (APINotFoundException $e) {
            try {
                $userGroup = $userService->loadUserGroup($spiRoleAssignment->contentId);
                $roleAssignment = $this->roleDomainMapper->buildDomainUserGroupRoleAssignmentObject($spiRoleAssignment, $userGroup, $role);
            } catch (APINotFoundException $e) {
                // Do nothing
            }
        }
        return $roleAssignment;
    }