Exemple #1
0
 /**
  * Moves the user group to another parent
  *
  * @param $groupPath
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  * @return \eZ\Publish\Core\REST\Server\Values\ResourceCreated
  */
 public function moveUserGroup($groupPath)
 {
     $userGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($groupPath));
     $userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId);
     $locationPath = $this->requestParser->parseHref($this->request->headers->get('Destination'), 'groupPath');
     try {
         $destinationGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($locationPath));
     } catch (APINotFoundException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     try {
         $destinationGroup = $this->userService->loadUserGroup($destinationGroupLocation->contentId);
     } catch (APINotFoundException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     $this->userService->moveUserGroup($userGroup, $destinationGroup);
     return new Values\ResourceCreated($this->router->generate('ezpublish_rest_loadUserGroup', array('groupPath' => $destinationGroupLocation->pathString . $userGroupLocation->id)));
 }
 /**
  * Moves the user group to another parent
  *
  * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
  * @param \eZ\Publish\API\Repository\Values\User\UserGroup $newParent
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group
  */
 public function moveUserGroup(UserGroup $userGroup, UserGroup $newParent)
 {
     $returnValue = $this->service->moveUserGroup($userGroup, $newParent);
     $this->signalDispatcher->emit(new MoveUserGroupSignal(array('userGroupId' => $userGroup->id, 'newParentId' => $newParent->id)));
     return $returnValue;
 }