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);
}