public function buildSPIFieldDefinitionUpdate(APIFieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct, APIFieldDefinition $fieldDefinition)
    {
        /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */
        $fieldType = $this->fieldTypeRegistry->getFieldType(
            $fieldDefinition->fieldTypeIdentifier
        );

        $validatorConfiguration = $fieldDefinitionUpdateStruct->validatorConfiguration === null
            ? $fieldDefinition->validatorConfiguration
            : $fieldDefinitionUpdateStruct->validatorConfiguration;
        $fieldSettings = $fieldDefinitionUpdateStruct->fieldSettings === null
            ? $fieldDefinition->fieldSettings
            : $fieldDefinitionUpdateStruct->fieldSettings;

        $validationErrors = array();
        if ($fieldDefinitionUpdateStruct->isSearchable && !$fieldType->isSearchable()) {
            $validationErrors[] = new ValidationError(
                "FieldType '{$fieldDefinition->fieldTypeIdentifier}' is not searchable"
            );
        }
        $validationErrors = array_merge(
            $validationErrors,
            $fieldType->validateValidatorConfiguration($validatorConfiguration),
            $fieldType->validateFieldSettings($fieldSettings)
        );

        if (!empty($validationErrors)) {
            throw new ContentTypeFieldDefinitionValidationException($validationErrors);
        }

        $spiFieldDefinition = new SPIFieldDefinition(
            array(
                'id' => $fieldDefinition->id,
                'fieldType' => $fieldDefinition->fieldTypeIdentifier,
                'name' => $fieldDefinitionUpdateStruct->names === null ?
                    $fieldDefinition->getNames() :
                    array_merge($fieldDefinition->getNames(), $fieldDefinitionUpdateStruct->names),
                'description' => $fieldDefinitionUpdateStruct->descriptions === null ?
                    $fieldDefinition->getDescriptions() :
                    array_merge($fieldDefinition->getDescriptions(), $fieldDefinitionUpdateStruct->descriptions),
                'identifier' => $fieldDefinitionUpdateStruct->identifier === null ?
                    $fieldDefinition->identifier :
                    $fieldDefinitionUpdateStruct->identifier,
                'fieldGroup' => $fieldDefinitionUpdateStruct->fieldGroup === null ?
                    $fieldDefinition->fieldGroup :
                    $fieldDefinitionUpdateStruct->fieldGroup,
                'position' => $fieldDefinitionUpdateStruct->position === null ?
                    $fieldDefinition->position :
                    $fieldDefinitionUpdateStruct->position,
                'isTranslatable' => $fieldDefinitionUpdateStruct->isTranslatable === null ?
                    $fieldDefinition->isTranslatable :
                    $fieldDefinitionUpdateStruct->isTranslatable,
                'isRequired' => $fieldDefinitionUpdateStruct->isRequired === null ?
                    $fieldDefinition->isRequired :
                    $fieldDefinitionUpdateStruct->isRequired,
                'isInfoCollector' => $fieldDefinitionUpdateStruct->isInfoCollector === null ?
                    $fieldDefinition->isInfoCollector :
                    $fieldDefinitionUpdateStruct->isInfoCollector,
                'isSearchable' => $fieldDefinitionUpdateStruct->isSearchable === null ?
                    $fieldDefinition->isSearchable :
                    $fieldDefinitionUpdateStruct->isSearchable,
                // These properties are precreated in constructor
                //"fieldTypeConstraints"
                //"defaultValue"
            )
        );

        $spiFieldDefinition->fieldTypeConstraints->validators = $validatorConfiguration;
        $spiFieldDefinition->fieldTypeConstraints->fieldSettings = $fieldSettings;
        $spiFieldDefinition->defaultValue = $fieldType->toPersistenceValue(
            $fieldType->acceptValue($fieldDefinitionUpdateStruct->defaultValue)
        );

        return $spiFieldDefinition;
    }
public function buildSPIFieldDefinitionUpdate(APIFieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct, APIFieldDefinition $fieldDefinition)
    {
        /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */
        $fieldType = $this->fieldTypeRegistry->getFieldType(
            $fieldDefinition->fieldTypeIdentifier
        );

        $validatorConfiguration = $fieldDefinitionUpdateStruct->validatorConfiguration === null
            ? $fieldDefinition->validatorConfiguration
            : $fieldDefinitionUpdateStruct->validatorConfiguration;
        $fieldSettings = $fieldDefinitionUpdateStruct->fieldSettings === null
            ? $fieldDefinition->fieldSettings
            : $fieldDefinitionUpdateStruct->fieldSettings;

        $validationErrors = array();
        if ($fieldDefinitionUpdateStruct->isSearchable && !$fieldType->isSearchable()) {
            $validationErrors[] = new ValidationError(
                "FieldType '{$fieldDefinition->fieldTypeIdentifier}' is not searchable"
            );
        }
        $validationErrors = array_merge(
            $validationErrors,
            $fieldType->validateValidatorConfiguration($validatorConfiguration),
            $fieldType->validateFieldSettings($fieldSettings)
        );

        if (!empty($validationErrors)) {
            throw new ContentTypeFieldDefinitionValidationException($validationErrors);
        }

        $spiFieldDefinition = new SPIFieldDefinition(
            array(
                'id' => $fieldDefinition->id,
                'fieldType' => $fieldDefinition->fieldTypeIdentifier,
                'name' => $fieldDefinitionUpdateStruct->names === null ?
                    $fieldDefinition->getNames() :
                    array_merge($fieldDefinition->getNames(), $fieldDefinitionUpdateStruct->names),
                'description' => $fieldDefinitionUpdateStruct->descriptions === null ?
                    $fieldDefinition->getDescriptions() :
                    array_merge($fieldDefinition->getDescriptions(), $fieldDefinitionUpdateStruct->descriptions),
                'identifier' => $fieldDefinitionUpdateStruct->identifier === null ?
                    $fieldDefinition->identifier :
                    $fieldDefinitionUpdateStruct->identifier,
                'fieldGroup' => $fieldDefinitionUpdateStruct->fieldGroup === null ?
                    $fieldDefinition->fieldGroup :
                    $fieldDefinitionUpdateStruct->fieldGroup,
                'position' => $fieldDefinitionUpdateStruct->position === null ?
                    $fieldDefinition->position :
                    $fieldDefinitionUpdateStruct->position,
                'isTranslatable' => $fieldDefinitionUpdateStruct->isTranslatable === null ?
                    $fieldDefinition->isTranslatable :
                    $fieldDefinitionUpdateStruct->isTranslatable,
                'isRequired' => $fieldDefinitionUpdateStruct->isRequired === null ?
                    $fieldDefinition->isRequired :
                    $fieldDefinitionUpdateStruct->isRequired,
                'isInfoCollector' => $fieldDefinitionUpdateStruct->isInfoCollector === null ?
                    $fieldDefinition->isInfoCollector :
                    $fieldDefinitionUpdateStruct->isInfoCollector,
                'isSearchable' => $fieldDefinitionUpdateStruct->isSearchable === null ?
                    $fieldDefinition->isSearchable :
                    $fieldDefinitionUpdateStruct->isSearchable,
                // These properties are precreated in constructor
                //"fieldTypeConstraints"
                //"defaultValue"
            )
        );

        $spiFieldDefinition->fieldTypeConstraints->validators = $validatorConfiguration;
        $spiFieldDefinition->fieldTypeConstraints->fieldSettings = $fieldSettings;
        $spiFieldDefinition->defaultValue = $fieldType->toPersistenceValue(
            $fieldType->acceptValue($fieldDefinitionUpdateStruct->defaultValue)
        );

        return $spiFieldDefinition;
    }
public function buildSPIFieldDefinitionUpdate ( APIFieldDefinitionUpdateStruct $ fieldDefinitionUpdateStruct , APIFieldDefinition $ fieldDefinition ) { /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */ $ fieldType = $ this -> fieldTypeRegistry -> getFieldType ( $ fieldDefinition -> fieldTypeIdentifier ) ; $ validatorConfiguration = $ fieldDefinitionUpdateStruct -> validatorConfiguration === null ? $ fieldDefinition -> validatorConfiguration : $ fieldDefinitionUpdateStruct -> validatorConfiguration ; $ fieldSettings = $ fieldDefinitionUpdateStruct -> fieldSettings === null ? $ fieldDefinition -> fieldSettings : $ fieldDefinitionUpdateStruct -> fieldSettings ; $ validationErrors = array ( ) ; if ( $ fieldDefinitionUpdateStruct -> isSearchable && ! $ fieldType -> isSearchable ( ) ) { $ validationErrors [ ] = new ValidationError ( "FieldType '{$fieldDefinition->fieldTypeIdentifier}' is not searchable" ) ; } $ validationErrors = array_merge ( $ validationErrors , $ fieldType -> validateValidatorConfiguration ( $ validatorConfiguration ) , $ fieldType -> validateFieldSettings ( $ fieldSettings ) ) ; if ( ! empty ( $ validationErrors ) ) { throw new ContentTypeFieldDefinitionValidationException ( $ validationErrors ) ; } $ spiFieldDefinition = new SPIFieldDefinition ( array ( 'id' => $ fieldDefinition -> id , 'fieldType' => $ fieldDefinition -> fieldTypeIdentifier , 'name' => $ fieldDefinitionUpdateStruct -> names === null ? $ fieldDefinition -> getNames ( ) : array_merge ( $ fieldDefinition -> getNames ( ) , $ fieldDefinitionUpdateStruct -> names ) , 'description' => $ fieldDefinitionUpdateStruct -> descriptions === null ? $ fieldDefinition -> getDescriptions ( ) : array_merge ( $ fieldDefinition -> getDescriptions ( ) , $ fieldDefinitionUpdateStruct -> descriptions ) , 'identifier' => $ fieldDefinitionUpdateStruct -> identifier === null ? $ fieldDefinition -> identifier : $ fieldDefinitionUpdateStruct -> identifier , 'fieldGroup' => $ fieldDefinitionUpdateStruct -> fieldGroup === null ? $ fieldDefinition -> fieldGroup : $ fieldDefinitionUpdateStruct -> fieldGroup , 'position' => $ fieldDefinitionUpdateStruct -> position === null ? $ fieldDefinition -> position : $ fieldDefinitionUpdateStruct -> position , 'isTranslatable' => $ fieldDefinitionUpdateStruct -> isTranslatable === null ? $ fieldDefinition -> isTranslatable : $ fieldDefinitionUpdateStruct -> isTranslatable , 'isRequired' => $ fieldDefinitionUpdateStruct -> isRequired === null ? $ fieldDefinition -> isRequired : $ fieldDefinitionUpdateStruct -> isRequired , 'isInfoCollector' => $ fieldDefinitionUpdateStruct -> isInfoCollector === null ? $ fieldDefinition -> isInfoCollector : $ fieldDefinitionUpdateStruct -> isInfoCollector , 'isSearchable' => $ fieldDefinitionUpdateStruct -> isSearchable === null ? $ fieldDefinition -> isSearchable : $ fieldDefinitionUpdateStruct -> isSearchable , // These properties are precreated in constructor //"fieldTypeConstraints" //"defaultValue" ) ) ; $ spiFieldDefinition -> fieldTypeConstraints -> validators = $ validatorConfiguration ; $ spiFieldDefinition -> fieldTypeConstraints -> fieldSettings = $ fieldSettings ; $ spiFieldDefinition -> defaultValue = $ fieldType -> toPersistenceValue ( $ fieldType -> acceptValue ( $ fieldDefinitionUpdateStruct -> defaultValue ) ) ; return $ spiFieldDefinition ; }
Builds SPIFieldDefinition object using API FieldDefinitionUpdateStruct
and API FieldDefinition.

@deprecated use \eZ\Publish\Core\Repository\Helper\ContentTypeDomainMapper::buildSPIFieldDefinitionFromUpdateStruct()

@throws \eZ\Publish\API\Repository\Exceptions\ContentTypeFieldDefinitionValidationException if validator configuration or
field setting do not validate

@param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct
@param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition $fieldDefinition

@return \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition
Builds SPIFieldDefinition object using API FieldDefinitionUpdateStruct and API FieldDefinition .