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

buildObjectStateGroupUpdateInputStruct() protected method

Validates input for updating object state groups and builds the InputStruct object.
protected buildObjectStateGroupUpdateInputStruct ( eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup, string $identifier, string $defaultLanguageCode, string[] $names, string[] $descriptions ) : eZ\Publish\SPI\Persistence\Content\ObjectState\InputStruct
$objectStateGroup eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
$identifier string
$defaultLanguageCode string
$names string[]
$descriptions string[]
return eZ\Publish\SPI\Persistence\Content\ObjectState\InputStruct
    protected function buildObjectStateGroupUpdateInputStruct(APIObjectStateGroup $objectStateGroup, $identifier, $defaultLanguageCode, $names, $descriptions)
    {
        $inputStruct = new InputStruct();
        if ($identifier !== null && (!is_string($identifier) || empty($identifier))) {
            throw new InvalidArgumentValue('identifier', $identifier);
        }
        $inputStruct->identifier = $identifier !== null ? $identifier : $objectStateGroup->identifier;
        if ($defaultLanguageCode !== null && (!is_string($defaultLanguageCode) || empty($defaultLanguageCode))) {
            throw new InvalidArgumentValue('defaultLanguageCode', $defaultLanguageCode);
        }
        $inputStruct->defaultLanguage = $defaultLanguageCode !== null ? $defaultLanguageCode : $objectStateGroup->defaultLanguageCode;
        if ($names !== null && (!is_array($names) || empty($names))) {
            throw new InvalidArgumentValue('names', $names);
        }
        $inputStruct->name = $names !== null ? $names : $objectStateGroup->getNames();
        if (!isset($inputStruct->name[$inputStruct->defaultLanguage])) {
            throw new InvalidArgumentValue('names', $inputStruct->name);
        }
        foreach ($inputStruct->name as $languageCode => $name) {
            try {
                $this->repository->getContentLanguageService()->loadLanguage($languageCode);
            } catch (NotFoundException $e) {
                throw new InvalidArgumentValue('names', $inputStruct->name);
            }
            if (!is_string($name) || empty($name)) {
                throw new InvalidArgumentValue('names', $inputStruct->name);
            }
        }
        if ($descriptions !== null && !is_array($descriptions)) {
            throw new InvalidArgumentValue('descriptions', $descriptions);
        }
        $descriptions = $descriptions !== null ? $descriptions : $objectStateGroup->getDescriptions();
        $descriptions = $descriptions !== null ? $descriptions : array();
        $inputStruct->description = array();
        foreach ($inputStruct->name as $languageCode => $name) {
            if (isset($descriptions[$languageCode]) && !empty($descriptions[$languageCode])) {
                $inputStruct->description[$languageCode] = $descriptions[$languageCode];
            } else {
                $inputStruct->description[$languageCode] = '';
            }
        }
        return $inputStruct;
    }