eZ\Publish\Core\Repository\ObjectStateService::createObjectStateGroup PHP Method

createObjectStateGroup() public method

Creates a new object state group.
public createObjectStateGroup ( eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct $objectStateGroupCreateStruct ) : eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
$objectStateGroupCreateStruct eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct
return eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
    public function createObjectStateGroup(ObjectStateGroupCreateStruct $objectStateGroupCreateStruct)
    {
        if ($this->repository->hasAccess('state', 'administrate') !== true) {
            throw new UnauthorizedException('state', 'administrate');
        }
        $inputStruct = $this->buildCreateInputStruct($objectStateGroupCreateStruct->identifier, $objectStateGroupCreateStruct->defaultLanguageCode, $objectStateGroupCreateStruct->names, $objectStateGroupCreateStruct->descriptions);
        try {
            $this->objectStateHandler->loadGroupByIdentifier($inputStruct->identifier);
            throw new InvalidArgumentException('objectStateGroupCreateStruct', 'Object state group with provided identifier already exists');
        } catch (APINotFoundException $e) {
            // Do nothing
        }
        $this->repository->beginTransaction();
        try {
            $spiObjectStateGroup = $this->objectStateHandler->createGroup($inputStruct);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
        return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup);
    }