eZ\Publish\Core\Repository\UserService::createUserGroup PHP Method

createUserGroup() public method

In 4.x in the content type parameter in the profile is ignored - the content type is determined via configuration and can be set to null. The returned version is published.
public createUserGroup ( eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct $userGroupCreateStruct, eZ\Publish\API\Repository\Values\User\UserGroup $parentGroup ) : eZ\Publish\API\Repository\Values\User\UserGroup
$userGroupCreateStruct eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct a structure for setting all necessary data to create this user group
$parentGroup eZ\Publish\API\Repository\Values\User\UserGroup
return eZ\Publish\API\Repository\Values\User\UserGroup
    public function createUserGroup(APIUserGroupCreateStruct $userGroupCreateStruct, APIUserGroup $parentGroup)
    {
        $contentService = $this->repository->getContentService();
        $locationService = $this->repository->getLocationService();
        $contentTypeService = $this->repository->getContentTypeService();
        if ($userGroupCreateStruct->contentType === null) {
            $userGroupContentType = $contentTypeService->loadContentType($this->settings['userGroupClassID']);
            $userGroupCreateStruct->contentType = $userGroupContentType;
        }
        $loadedParentGroup = $this->loadUserGroup($parentGroup->id);
        if ($loadedParentGroup->getVersionInfo()->getContentInfo()->mainLocationId === null) {
            throw new InvalidArgumentException('parentGroup', 'parent user group has no main location');
        }
        $locationCreateStruct = $locationService->newLocationCreateStruct($loadedParentGroup->getVersionInfo()->getContentInfo()->mainLocationId);
        $this->repository->beginTransaction();
        try {
            $contentDraft = $contentService->createContent($userGroupCreateStruct, array($locationCreateStruct));
            $publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
        return $this->buildDomainUserGroupObject($publishedContent);
    }