예제 #1
0
 /**
  * Given user group is deleted
  *
  * @param $groupPath
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  * @return \eZ\Publish\Core\REST\Server\Values\NoContent
  */
 public function deleteUserGroup($groupPath)
 {
     $userGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($groupPath));
     $userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId);
     // Load one user to see if user group is empty or not
     $users = $this->userService->loadUsersOfUserGroup($userGroup, 0, 1);
     if (!empty($users)) {
         throw new Exceptions\ForbiddenException("Non-empty user groups cannot be deleted");
     }
     $this->userService->deleteUserGroup($userGroup);
     return new Values\NoContent();
 }
 /**
  * Removes a user group
  *
  * the users which are not assigned to other groups will be deleted.
  *
  * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group
  */
 public function deleteUserGroup(UserGroup $userGroup)
 {
     $returnValue = $this->service->deleteUserGroup($userGroup);
     $this->signalDispatcher->emit(new DeleteUserGroupSignal(array('userGroupId' => $userGroup->id)));
     return $returnValue;
 }