public function updateUserGroup(APIUserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct)
{
if ($userGroupUpdateStruct->contentUpdateStruct === null && $userGroupUpdateStruct->contentMetadataUpdateStruct === null) {
// both update structs are empty, nothing to do
return $userGroup;
}
$contentService = $this->repository->getContentService();
$loadedUserGroup = $this->loadUserGroup($userGroup->id);
$this->repository->beginTransaction();
try {
$publishedContent = $loadedUserGroup;
if ($userGroupUpdateStruct->contentUpdateStruct !== null) {
$contentDraft = $contentService->createContentDraft($loadedUserGroup->getVersionInfo()->getContentInfo());
$contentDraft = $contentService->updateContent($contentDraft->getVersionInfo(), $userGroupUpdateStruct->contentUpdateStruct);
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());
}
if ($userGroupUpdateStruct->contentMetadataUpdateStruct !== null) {
$publishedContent = $contentService->updateContentMetadata($publishedContent->getVersionInfo()->getContentInfo(), $userGroupUpdateStruct->contentMetadataUpdateStruct);
}
$this->repository->commit();
} catch (Exception $e) {
$this->repository->rollback();
throw $e;
}
return $this->buildDomainUserGroupObject($publishedContent);
}