Copied!

FieldType

FieldType.php : 19

Interface that FieldTypes expose to the public API.

Tags
See
FieldType

For implementer doc

Methods

publicfieldSettingsFromHash()

FieldType.php : 176

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

public fieldSettingsFromHash(array<string|int, mixed>|scalar|null $fieldSettingsHash) : mixed

This is the reverse operation of FieldType::fieldSettingsToHash().

Parameters

Name Type Default value Description
$fieldSettingsHash array<string|int, mixed>|scalar|null - -

publicfieldSettingsToHash()

FieldType.php : 165

Converts the given $fieldSettings to a simple hash format.

public fieldSettingsToHash(mixed $fieldSettings) : array<string|int, mixed>|scalar|null

Parameters

Name Type Default value Description
$fieldSettings mixed - -

Return values

array<string|int, mixed>|scalar|null

publicfromHash()

FieldType.php : 147

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

public fromHash(mixed $hash) : mixed

This is the reverse operation to FieldType::toHash().

Parameters

Name Type Default value Description
$hash mixed - -

publicgetEmptyValue()

FieldType.php : 121

Returns the empty value for this field type.

public getEmptyValue() : mixed

publicgetFieldTypeIdentifier()

FieldType.php : 26

Returns the field type identifier for this field type.

public getFieldTypeIdentifier() : string

Return values

string

publicgetName()

FieldType.php : 31

Returns a human readable string representation from the given $value.

public getName(Value $value, FieldDefinition $fieldDefinition, string $languageCode) : string

Parameters

Name Type Default value Description
$value Value - -
$fieldDefinition FieldDefinition - -
$languageCode string - -

Return values

string

publicgetSettingsSchema()

FieldType.php : 52

Returns a schema for the settings expected by the FieldType.

public getSettingsSchema() : mixed

Returns an arbitrary value, representing a schema for the settings of the FieldType.

Explanation: There are no possible generic schemas for defining settings input, which is why no schema for the return value of this method is defined. It is up to the implementer to define and document a schema for the return value and document it. In addition, it is necessary that all consumers of this interface (e.g. Public API, REST API, GUIs, ...) provide plugin mechanisms to hook adapters for the specific FieldType into. These adapters then need to be either shipped with the FieldType or need to be implemented by a third party. If there is no adapter available for a specific FieldType, it will not be usable with the consumer.

publicgetValidatorConfigurationSchema()

FieldType.php : 93

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

public getValidatorConfigurationSchema() : mixed

Returns an arbitrary value, representing a schema for the validator configuration of the FieldType.

Explanation: There are no possible generic schemas for defining settings input, which is why no schema for the return value of this method is defined. It is up to the implementer to define and document a schema for the return value and document it. In addition, it is necessary that all consumers of this interface (e.g. Public API, REST API, GUIs, ...) provide plugin mechanisms to hook adapters for the specific FieldType into. These adapters then need to be either shipped with the FieldType or need to be implemented by a third party. If there is no adapter available for a specific FieldType, it will not be usable with the consumer.

Best practice:

It is considered best practice to return a hash map, which contains rudimentary settings structures, like e.g. for the "ezstring" FieldType

array( 'stringLength' => array( 'minStringLength' => array( 'type' => 'int', 'default' => 0, ), 'maxStringLength' => array( 'type' => 'int' 'default' => null, ) ), );

publicisEmptyValue()

FieldType.php : 136

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

public isEmptyValue(mixed $value) : bool

Usually, only the value returned by FieldType::getEmptyValue() is considered empty but that is not always the case.

Note: This function assumes that $value is valid so this function can only be used reliably on $values that came from the API, not from the user.

Parameters

Name Type Default value Description
$value mixed - -

Return values

bool

publicisSearchable()

FieldType.php : 100

Indicates if the field type supports indexing and sort keys for searching.

public isSearchable() : bool

Return values

bool

publicisSingular()

FieldType.php : 107

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

public isSingular() : bool

Return values

bool

publiconlyEmptyInstance()

FieldType.php : 114

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

public onlyEmptyInstance() : bool

Return values

bool

publictoHash()

FieldType.php : 156

Converts the given $value into a plain hash format.

public toHash(mixed $value) : mixed

Parameters

Name Type Default value Description
$value mixed - -

publicvalidateFieldSettings()

FieldType.php : 219

Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

public validateFieldSettings(mixed $fieldSettings) : array<string|int, ValidationError>

This methods determines if the given $fieldSettings are structurally correct and comply to the settings schema as defined in FieldType.

Parameters

Name Type Default value Description
$fieldSettings mixed - -

Return values

array<string|int, ValidationError>

publicvalidateValidatorConfiguration()

FieldType.php : 207

Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

public validateValidatorConfiguration(mixed $validatorConfiguration) : array<string|int, ValidationError>

This methods determines if the given $validatorConfiguration is structurally correct and complies to the validator configuration schema as defined in FieldType.

Parameters

Name Type Default value Description
$validatorConfiguration mixed - -

Return values

array<string|int, ValidationError>

publicvalidateValue()

FieldType.php : 229

Validates a field value based on the validator configuration in the field definition.

public validateValue(FieldDefinition $fieldDef, Value $value) : array<string|int, ValidationError>

Parameters

Name Type Default value Description
$fieldDef FieldDefinition -

The field definition of the field

$value Value -

The field value for which an action is performed

Return values

array<string|int, ValidationError>

publicvalidatorConfigurationFromHash()

FieldType.php : 195

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

public validatorConfigurationFromHash(array<string|int, mixed>|scalar|null $validatorConfigurationHash) : mixed

Parameters

Name Type Default value Description
$validatorConfigurationHash array<string|int, mixed>|scalar|null - -

publicvalidatorConfigurationToHash()

FieldType.php : 185

Converts the given $validatorConfiguration to a simple hash format.

public validatorConfigurationToHash(mixed $validatorConfiguration) : array<string|int, mixed>|scalar|null

Parameters

Name Type Default value Description
$validatorConfiguration mixed - -

Return values

array<string|int, mixed>|scalar|null