Class

eZ\Publish\Core\FieldType\Keyword\Type

class Type extends FieldType

Keyword field types.

Represents keywords.

Methods

setTransformationProcessor(TransformationProcessor $transformationProcessor)

from FieldType
mixed getSettingsSchema()

Returns a schema for the settings expected by the FieldType.

from FieldType
mixed getValidatorConfigurationSchema()

Returns a schema for the validator configuration expected by the FieldType.

from FieldType
ValidationError[] validate(FieldDefinition $fieldDefinition, Value $value)

Validates a field based on the validators in the field definition.

from FieldType
ValidationError[] validateValidatorConfiguration(mixed $validatorConfiguration)

Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

from FieldType
applyDefaultValidatorConfiguration(mixed $validatorConfiguration)

Applies the default values to the given $validatorConfiguration of a FieldDefinitionCreateStruct.

from FieldType
ValidationError[] validateFieldSettings(mixed $fieldSettings)

Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

from FieldType
applyDefaultSettings(mixed $fieldSettings)

Applies the default values to the fieldSettings of a FieldDefinitionCreateStruct.

from FieldType
FieldValue toPersistenceValue(Value $value)

Converts a $value to a persistence value.

Value fromPersistenceValue(FieldValue $fieldValue)

Converts a persistence $fieldValue to a Value.

bool isSearchable()

Returns whether the field type is searchable.

bool isSingular()

Indicates if the field definition of this type can appear only once in the same ContentType.

from FieldType
bool onlyEmptyInstance()

Indicates if the field definition of this type can be added to a ContentType with Content instances.

from FieldType
bool isEmptyValue(Value $value)

Returns if the given $value is considered empty by the field type.

from FieldType
Value acceptValue(mixed $inputValue)

Potentially builds and checks the type and structure of the $inputValue.

from FieldType
array|hash|scalar|null fieldSettingsToHash(mixed $fieldSettings)

Converts the given $fieldSettings to a simple hash format.

from FieldType
mixed fieldSettingsFromHash(array|hash|scalar|null $fieldSettingsHash)

Converts the given $fieldSettingsHash to field settings of the type.

from FieldType
array|hash|scalar|null validatorConfigurationToHash(mixed $validatorConfiguration)

Converts the given $validatorConfiguration to a simple hash format.

from FieldType
mixed validatorConfigurationFromHash(array|hash|scalar|null $validatorConfigurationHash)

Converts the given $validatorConfigurationHash to a validator configuration of the type.

from FieldType
array getRelations(Value $fieldValue)

Returns relation data extracted from value.

from FieldType
string getFieldTypeIdentifier()

Returns the field type identifier for this field type.

string getName(Value $value)

Returns the name of the given field value.

Value getEmptyValue()

Returns the fallback default value of field type when no such default value is provided in the field definition in content types.

Value fromHash(mixed $hash)

Converts an $hash to the Value defined by the field type.

mixed toHash(Value $value)

Converts a $Value to a hash.

Details

in FieldType at line 70
public setTransformationProcessor(TransformationProcessor $transformationProcessor)

Parameters

TransformationProcessor $transformationProcessor

in FieldType at line 84
public mixed getSettingsSchema()

Returns a schema for the settings expected by the FieldType.

This implementation returns an array. where the key is the setting name, and the value is the default value for given setting and set to null if no particular default should be set.

Return Value

mixed

in FieldType at line 115
public mixed getValidatorConfigurationSchema()

Returns a schema for the validator configuration expected by the FieldType.

Return Value

mixed

See also

FieldTypeInterface::getValidatorConfigurationSchema() This implementation returns a three dimensional map containing for each validator configuration referenced by identifier a map of supported parameters which are defined by a type and a default value (see example). <code> array( 'stringLength' => array( 'minStringLength' => array( 'type' => 'int', 'default' => 0, ), 'maxStringLength' => array( 'type' => 'int' 'default' => null, ) ), ); </code>

in FieldType at line 134
public ValidationError[] validate(FieldDefinition $fieldDefinition, Value $value)

Validates a field based on the validators in the field definition.

This is a base implementation, returning an empty array() that indicates that no validation errors occurred. Overwrite in derived types, if validation is supported.

Parameters

FieldDefinition $fieldDefinition The field definition of the field
Value $value The field value for which an action is performed

Return Value

ValidationError[]

Exceptions

InvalidArgumentException

in FieldType at line 153
public ValidationError[] validateValidatorConfiguration(mixed $validatorConfiguration)

Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

This method expects that given $validatorConfiguration is complete, for this purpose method {@link self::applyDefaultValidatorConfiguration()} is provided.

This is a base implementation, returning a validation error for each specified validator, since by default no validators are supported. Overwrite in derived types, if validation is supported.

Parameters

mixed $validatorConfiguration

Return Value

ValidationError[]

in FieldType at line 181
public applyDefaultValidatorConfiguration(mixed $validatorConfiguration)

Applies the default values to the given $validatorConfiguration of a FieldDefinitionCreateStruct.

This is a base implementation, expecting best practice validator configuration format used by field types in standard eZ publish installation. Overwrite in derived types if needed.

Parameters

mixed $validatorConfiguration

Exceptions

InvalidArgumentException

in FieldType at line 212
public ValidationError[] validateFieldSettings(mixed $fieldSettings)

Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

This method expects that given $fieldSettings are complete, for this purpose method {@link self::applyDefaultSettings()} is provided.

Parameters

mixed $fieldSettings

Return Value

ValidationError[]

in FieldType at line 240
public applyDefaultSettings(mixed $fieldSettings)

Applies the default values to the fieldSettings of a FieldDefinitionCreateStruct.

This is a base implementation, expecting best practice field settings format used by field types in standard eZ publish installation. Overwrite in derived types if needed.

Parameters

mixed $fieldSettings

Exceptions

InvalidArgumentException

at line 151
public FieldValue toPersistenceValue(Value $value)

Converts a $value to a persistence value.

Parameters

Value $value The value of the field type

Return Value

FieldValue the value processed by the storage engine

at line 169
public Value fromPersistenceValue(FieldValue $fieldValue)

Converts a persistence $fieldValue to a Value.

Parameters

FieldValue $fieldValue

Return Value

Value

at line 139
public bool isSearchable()

Returns whether the field type is searchable.

Return Value

bool

in FieldType at line 323
public bool isSingular()

Indicates if the field definition of this type can appear only once in the same ContentType.

Return Value

bool

in FieldType at line 333
public bool onlyEmptyInstance()

Indicates if the field definition of this type can be added to a ContentType with Content instances.

Return Value

bool

in FieldType at line 349
public bool isEmptyValue(Value $value)

Returns if the given $value is considered empty by the field type.

Default implementation, which performs a "==" check with the value returned by {@link getEmptyValue()}. Overwrite in the specific field type, if necessary.

Parameters

Value $value

Return Value

bool

in FieldType at line 375
final public Value acceptValue(mixed $inputValue)

Potentially builds and checks the type and structure of the $inputValue.

This method first inspects $inputValue and convert it into a dedicated value object.

After that, the value is checked for structural validity. Note that this does not include validation after the rules from validators, but only plausibility checks for the general data format.

Note that this method must also cope with the empty value for the field type as e.g. returned by {@link getEmptyValue()}.

Parameters

mixed $inputValue

Return Value

Value The potentially converted and structurally plausible value.

Exceptions

InvalidArgumentException if the parameter is not of the supported value sub type
InvalidArgumentException if the value does not match the expected structure

in FieldType at line 491
public array|hash|scalar|null fieldSettingsToHash(mixed $fieldSettings)

Converts the given $fieldSettings to a simple hash format.

This is the default implementation, which just returns the given $fieldSettings, assuming they are already in a hash format. Overwrite this in your specific implementation, if necessary.

Parameters

mixed $fieldSettings

Return Value

array|hash|scalar|null

in FieldType at line 510
public mixed fieldSettingsFromHash(array|hash|scalar|null $fieldSettingsHash)

Converts the given $fieldSettingsHash to field settings of the type.

This is the reverse operation of {@link fieldSettingsToHash()}.

This is the default implementation, which just returns the given $fieldSettingsHash, assuming the supported field settings are already in a hash format. Overwrite this in your specific implementation, if necessary.

Parameters

array|hash|scalar|null $fieldSettingsHash

Return Value

mixed

in FieldType at line 526
public array|hash|scalar|null validatorConfigurationToHash(mixed $validatorConfiguration)

Converts the given $validatorConfiguration to a simple hash format.

Default implementation, which just returns the given $validatorConfiguration, which is by convention an array for all internal field types. Overwrite this method, if necessary.

Parameters

mixed $validatorConfiguration

Return Value

array|hash|scalar|null

in FieldType at line 544
public mixed validatorConfigurationFromHash(array|hash|scalar|null $validatorConfigurationHash)

Converts the given $validatorConfigurationHash to a validator configuration of the type.

Default implementation, which just returns the given $validatorConfigurationHash, since the validator configuration is by convention an array for all internal field types. Overwrite this method, if necessary.

Parameters

array|hash|scalar|null $validatorConfigurationHash

Return Value

mixed

in FieldType at line 574
public array getRelations(Value $fieldValue)

Returns relation data extracted from value.

Not intended for \eZ\Publish\API\Repository\Values\Content\Relation::COMMON type relations, there is an API for handling those.

Parameters

Value $fieldValue

Return Value

array Hash with relation type as key and array of destination content ids as value. Example: array( \eZ\Publish\API\Repository\Values\Content\Relation::LINK => array( "contentIds" => array( 12, 13, 14 ), "locationIds" => array( 24 ) ), \eZ\Publish\API\Repository\Values\Content\Relation::EMBED => array( "contentIds" => array( 12 ), "locationIds" => array( 24, 45 ) ), \eZ\Publish\API\Repository\Values\Content\Relation::FIELD => array( 12 ) )

at line 29
public string getFieldTypeIdentifier()

Returns the field type identifier for this field type.

Return Value

string

at line 44
public string getName(Value $value)

Returns the name of the given field value.

It will be used to generate content name and url alias if current field is designated to be used in the content name/urlAlias pattern.

Parameters

Value $value

Return Value

string

at line 55
public Value getEmptyValue()

Returns the fallback default value of field type when no such default value is provided in the field definition in content types.

Return Value

Value

at line 117
public Value fromHash(mixed $hash)

Converts an $hash to the Value defined by the field type.

Parameters

mixed $hash

Return Value

Value $value

at line 129
public mixed toHash(Value $value)

Converts a $Value to a hash.

Parameters

Value $value

Return Value

mixed