FieldType
Interface that FieldTypes expose to the public API.
Tags
Methods¶
fieldSettingsFromHash()
¶
Converts the given $fieldSettingsHash to field settings of the type.
|
|
This is the reverse operation of FieldType::fieldSettingsToHash().
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$fieldSettingsHash | array<string|int, mixed>|scalar|null | - | - |
fieldSettingsToHash()
¶
Converts the given $fieldSettings to a simple hash format.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$fieldSettings | mixed | - | - |
Return values
array<string|int, mixed>|scalar|null
fromHash()
¶
Converts an $hash to the Value defined by the field type.
|
|
This is the reverse operation to FieldType::toHash().
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$hash | mixed | - | - |
getEmptyValue()
¶
Returns the empty value for this field type.
|
|
getFieldTypeIdentifier()
¶
Returns the field type identifier for this field type.
|
|
Return values
string
getName()
¶
Returns a human readable string representation from the given $value.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$value | Value | - | - |
$fieldDefinition | FieldDefinition | - | - |
$languageCode | string | - | - |
Return values
string
getSettingsSchema()
¶
Returns a schema for the settings expected by the FieldType.
|
|
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.
getValidatorConfigurationSchema()
¶
Returns a schema for the validator configuration expected by the FieldType.
|
|
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,
)
),
);
isEmptyValue()
¶
Returns if the given $value is considered empty by the field type.
|
|
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
isSearchable()
¶
Indicates if the field type supports indexing and sort keys for searching.
|
|
Return values
bool
isSingular()
¶
Indicates if the field definition of this type can appear only once in the same ContentType.
|
|
Return values
bool
onlyEmptyInstance()
¶
Indicates if the field definition of this type can be added to a ContentType with Content instances.
|
|
Return values
bool
toHash()
¶
Converts the given $value into a plain hash format.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$value | mixed | - | - |
validateFieldSettings()
¶
Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.
|
|
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>
validateValidatorConfiguration()
¶
Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.
|
|
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>
validateValue()
¶
Validates a field value based on the validator configuration in the field definition.
|
|
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>
validatorConfigurationFromHash()
¶
Converts the given $validatorConfigurationHash to a validator configuration of the type.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$validatorConfigurationHash | array<string|int, mixed>|scalar|null | - | - |
validatorConfigurationToHash()
¶
Converts the given $validatorConfiguration to a simple hash format.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$validatorConfiguration | mixed | - | - |
Return values
array<string|int, mixed>|scalar|null