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

updateObjectStateGroup() public method

Updates an object state group.
public updateObjectStateGroup ( eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup, eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupUpdateStruct $objectStateGroupUpdateStruct ) : eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
$objectStateGroup eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
$objectStateGroupUpdateStruct eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupUpdateStruct
return eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
    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);
    }