eZ\Publish\Core\REST\Server\Controller\User::moveUserGroup PHP Method

moveUserGroup() public method

Moves the user group to another parent.
public moveUserGroup ( $groupPath, Request $request ) : ResourceCreated
$groupPath
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\ResourceCreated
    public function moveUserGroup($groupPath, Request $request)
    {
        $userGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($groupPath));
        $userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId);
        $locationPath = $this->requestParser->parseHref($request->headers->get('Destination'), 'groupPath');
        try {
            $destinationGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($locationPath));
        } catch (ApiExceptions\NotFoundException $e) {
            throw new Exceptions\ForbiddenException($e->getMessage());
        }
        try {
            $destinationGroup = $this->userService->loadUserGroup($destinationGroupLocation->contentId);
        } catch (ApiExceptions\NotFoundException $e) {
            throw new Exceptions\ForbiddenException($e->getMessage());
        }
        $this->userService->moveUserGroup($userGroup, $destinationGroup);
        return new Values\ResourceCreated($this->router->generate('ezpublish_rest_loadUserGroup', array('groupPath' => trim($destinationGroupLocation->pathString, '/') . '/' . $userGroupLocation->id)));
    }