Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Public Member Functions | Protected Attributes | List of all members
eZ\Publish\Core\Repository\Values\ContentType\FieldType Class Reference

This class represents a FieldType available to Public API users. More...

Inheritance diagram for eZ\Publish\Core\Repository\Values\ContentType\FieldType:

## Public Member Functions
| __construct (SPIFieldTypeInterface $fieldType)
| getFieldTypeIdentifier ()
| Returns the field type identifier for this field type. More...
| getName ($value)
| getSettingsSchema ()
| Returns a schema for the settings expected by the FieldType. More...
| getValidatorConfigurationSchema ()
| Returns a schema for the validator configuration expected by the FieldType. More...
| isSearchable ()
| Indicates if the field type supports indexing and sort keys for searching. More...
| isSingular ()
| Indicates if the field definition of this type can appear only once in the same ContentType. More...
| onlyEmptyInstance ()
| Indicates if the field definition of this type can be added to a ContentType with Content instances. More...
| getEmptyValue ()
| Returns the fallback default value of field type when no such default value is provided in the field definition in content types. More...
| isEmptyValue ($value)
| Returns if the given $value is considered empty by the field type. More...
| fromHash ($hash)
| Converts an $hash to the Value defined by the field type. More...
| toHash ($value)
| Converts a Value to a hash. More...
| fieldSettingsToHash ($fieldSettings)
| Converts the given $fieldSettings to a simple hash format. More...
| fieldSettingsFromHash ($fieldSettingsHash)
| Converts the given $fieldSettingsHash to field settings of the type. More...
| validatorConfigurationToHash ($validatorConfiguration)
| Converts the given $validatorConfiguration to a simple hash format. More...
| validatorConfigurationFromHash ($validatorConfigurationHash)
| Converts the given $validatorConfigurationHash to a validator configuration of the type. More...
| validateValidatorConfiguration ($validatorConfiguration)
| Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct. More...
| validateFieldSettings ($fieldSettings)
| Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct. More...
| validateValue (APIFieldDefinition $fieldDef, Value $value)
| Validates a field value based on the validator configuration in the field definition. More...
Public Member Functions inherited from eZ\Publish\SPI\FieldType\FieldType
| getName (Value $value)
| Returns a human readable string representation from the given $value. More...
| validate (FieldDefinition $fieldDef, Value $value)
| Validates a field based on the validator configuration in the field definition. More...
| applyDefaultValidatorConfiguration (&$validatorConfiguration)
| Applies the default values to the given $validatorConfiguration of a FieldDefinitionCreateStruct. More...
| applyDefaultSettings (&$fieldSettings)
| Applies the default values to the fieldSettings of a FieldDefinitionCreateStruct. More...
| isEmptyValue (Value $value)
| Returns if the given $value is considered empty by the field type. More...
| acceptValue ($inputValue)
| Potentially builds and checks the type and structure of the $inputValue. More...
| toHash (Value $value)
| Converts the given $value into a plain hash format. More...
| toPersistenceValue (Value $value)
| Converts a $value to a persistence value. More...
| fromPersistenceValue (FieldValue $fieldValue)
| Converts a persistence $value to a Value. More...
| getRelations (Value $value)
| Returns relation data extracted from value. More...

## Protected Attributes
| $internalFieldType

## Detailed Description

This class represents a FieldType available to Public API users.

See also
  eZ\Publish\API\Repository\FieldType

Meant for internal use by Repository, type hint against API object instead.

Definition at line 21 of file Core/Repository/Values/ContentType/FieldType.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::__construct | ( | SPIFieldTypeInterface | $fieldType | ) |

Parameters

  \eZ\Publish\SPI\FieldType\FieldType | $fieldType |

Definition at line 33 of file Core/Repository/Values/ContentType/FieldType.php.

## Member Function Documentation

## ◆ fieldSettingsFromHash()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::fieldSettingsFromHash | ( |  | $fieldSettingsHash | ) |

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

This is the reverse operation of fieldSettingsToHash().

Parameters

  array | hash | scalar | null | $fieldSettingsHash |

Returns
  mixed

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 225 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ fieldSettingsToHash()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::fieldSettingsToHash | ( |  | $fieldSettings | ) |

Converts the given $fieldSettings to a simple hash format.

Parameters

  mixed | $fieldSettings |

Returns
  array|hash|scalar|null

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 211 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ fromHash()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::fromHash | ( |  | $hash | ) |

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

Parameters

  mixed | $hash |

Returns
  mixed

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 187 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ getEmptyValue()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::getEmptyValue | ( |  | ) |

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

Returns
  mixed

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 157 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ getFieldTypeIdentifier()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::getFieldTypeIdentifier | ( |  | ) |

Returns the field type identifier for this field type.

Returns
  string

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 43 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ getName()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::getName | ( |  | $value | ) |

Definition at line 48 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ getSettingsSchema()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::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.

Returns
  mixed

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 72 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ getValidatorConfigurationSchema()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::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, ) ), );`

Returns
  mixed

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 116 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ isEmptyValue()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::isEmptyValue | ( |  | $value | ) |

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

Usually, only the value returned by 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

  mixed | $value |

Returns
  bool

Definition at line 175 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ isSearchable()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::isSearchable | ( |  | ) |

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

Returns
  bool

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 126 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ isSingular()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::isSingular | ( |  | ) |

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

Returns
  bool

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 136 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ onlyEmptyInstance()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::onlyEmptyInstance | ( |  | ) |

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

Returns
  bool

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 146 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ toHash()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::toHash | ( |  | $value | ) |

Converts a Value to a hash.

Parameters

  mixed | $value |

Returns
  mixed

Definition at line 199 of file Core/Repository/Values/ContentType/FieldType.php.

Referenced by eZ\Publish\Core\Repository\ContentService\fieldValuesAreEqual().

## ◆ validateFieldSettings()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::validateFieldSettings | ( |  | $fieldSettings | ) |

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

  mixed | $fieldSettings |

Returns
  \eZ\Publish\SPI\FieldType\ValidationError[]

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 280 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ validateValidatorConfiguration()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::validateValidatorConfiguration | ( |  | $validatorConfiguration | ) |

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

  mixed | $validatorConfiguration |

Returns
  \eZ\Publish\SPI\FieldType\ValidationError[]

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 265 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ validateValue()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::validateValue | ( | APIFieldDefinition | $fieldDef,
|  | Value | $value
| ) |  |

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

Parameters

  \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition | $fieldDef | The field definition of the field
  \eZ\Publish\SPI\FieldType\Value | $value | The field value for which an action is performed

Returns
  \eZ\Publish\SPI\FieldType\ValidationError[]

Definition at line 293 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ validatorConfigurationFromHash()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::validatorConfigurationFromHash | ( |  | $validatorConfigurationHash | ) |

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

Parameters

  array | hash | scalar | null | $validatorConfigurationHash |

Returns
  mixed

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 250 of file Core/Repository/Values/ContentType/FieldType.php.

## ◆ validatorConfigurationToHash()

eZ\Publish\Core\Repository\Values\ContentType\FieldType::validatorConfigurationToHash | ( |  | $validatorConfiguration | ) |

Converts the given $validatorConfiguration to a simple hash format.

Parameters

  mixed | $validatorConfiguration |

Returns
  array|hash|scalar|null

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 237 of file Core/Repository/Values/ContentType/FieldType.php.

## Member Data Documentation

## ◆ $internalFieldType

eZ\Publish\Core\Repository\Values\ContentType\FieldType::$internalFieldType
| protected

Definition at line 28 of file Core/Repository/Values/ContentType/FieldType.php.

The documentation for this class was generated from the following file:

- Core/Repository/Values/ContentType/FieldType.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.