public function updateObjectStateGroup(APIObjectStateGroup $objectStateGroup, ObjectStateGroupUpdateStruct $objectStateGroupUpdateStruct)
{
if ($this->repository->hasAccess('state', 'administrate') !== true) {
throw new UnauthorizedException('state', 'administrate');
}
$loadedObjectStateGroup = $this->loadObjectStateGroup($objectStateGroup->id);
$inputStruct = $this->buildObjectStateGroupUpdateInputStruct($loadedObjectStateGroup, $objectStateGroupUpdateStruct->identifier, $objectStateGroupUpdateStruct->defaultLanguageCode, $objectStateGroupUpdateStruct->names, $objectStateGroupUpdateStruct->descriptions);
if ($objectStateGroupUpdateStruct->identifier !== null) {
try {
$existingObjectStateGroup = $this->objectStateHandler->loadGroupByIdentifier($inputStruct->identifier);
if ($existingObjectStateGroup->id != $loadedObjectStateGroup->id) {
throw new InvalidArgumentException('objectStateGroupUpdateStruct', 'Object state group with provided identifier already exists');
}
} catch (APINotFoundException $e) {
// Do nothing
}
}
$this->repository->beginTransaction();
try {
$spiObjectStateGroup = $this->objectStateHandler->updateGroup($loadedObjectStateGroup->id, $inputStruct);
$this->repository->commit();
} catch (Exception $e) {
$this->repository->rollback();
throw $e;
}
return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup);
}