public function unassignUserFromUserGroup($userId, $groupPath)
{
$user = $this->userService->loadUser($userId);
$userGroupLocation = $this->locationService->loadLocation(trim($groupPath, '/'));
$userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId);
try {
$this->userService->unAssignUserFromUserGroup($user, $userGroup);
} catch (ApiExceptions\InvalidArgumentException $e) {
// User is not in the group
throw new Exceptions\ForbiddenException($e->getMessage());
}
$userGroups = $this->userService->loadUserGroupsOfUser($user);
$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\UserGroupRefList($restUserGroups, $this->router->generate('ezpublish_rest_loadUserGroupsOfUser', array('userId' => $userId)), $userId);
}