PHP Класс eZ\Publish\Core\FieldType\FieldType

All other field types extend FieldType providing the specific functionality desired in each case. The capabilities supported by each individual field type is decided by which interfaces the field type implements support for. These individual capabilities can also be checked via the supports*() methods. Field types are the base building blocks of Content Types, and serve as data containers for Content objects. Therefore, while field types can be used independently, they are designed to be used as a part of a Content object. Field types are primed and pre-configured with the Field Definitions found in Content Types.
Наследование: implements eZ\Publish\SPI\FieldType\FieldType
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$settingsSchema mixed The key is the setting name, and the value is the default value for given setting, set to null if no particular default should be set.
$transformationProcessor eZ\Publish\Core\Persistence\TransformationProcessor String transformation processor, used to normalize sort string as needed.
$validatorConfigurationSchema mixed This is a base implementation, containing an empty array() that indicates that no validators are supported. Overwrite in derived types, if validation is supported.

Открытые методы

Метод Описание
acceptValue ( mixed $inputValue ) : Value Potentially builds and checks the type and structure of the $inputValue.
applyDefaultSettings ( mixed &$fieldSettings ) Applies the default values to the fieldSettings of a FieldDefinitionCreateStruct.
applyDefaultValidatorConfiguration ( mixed &$validatorConfiguration ) Applies the default values to the given $validatorConfiguration of a FieldDefinitionCreateStruct.
fieldSettingsFromHash ( array | hash | scalar | null $fieldSettingsHash ) : mixed Converts the given $fieldSettingsHash to field settings of the type.
fieldSettingsToHash ( mixed $fieldSettings ) : array | hash | scalar | null Converts the given $fieldSettings to a simple hash format.
fromPersistenceValue ( eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue ) : Value Converts a persistence $fieldValue to a Value.
getRelations ( eZ\Publish\SPI\FieldType\Value $fieldValue ) : array Returns relation data extracted from value.
getSettingsSchema ( ) : mixed Returns a schema for the settings expected by the FieldType.
getValidatorConfigurationSchema ( ) : mixed Returns a schema for the validator configuration expected by the FieldType.
isEmptyValue ( eZ\Publish\SPI\FieldType\Value $value ) : boolean Returns if the given $value is considered empty by the field type.
isSearchable ( ) : boolean Returns whether the field type is searchable.
isSingular ( ) : boolean Indicates if the field definition of this type can appear only once in the same ContentType.
onlyEmptyInstance ( ) : boolean Indicates if the field definition of this type can be added to a ContentType with Content instances.
setTransformationProcessor ( TransformationProcessor $transformationProcessor )
toPersistenceValue ( eZ\Publish\SPI\FieldType\Value $value ) : eZ\Publish\SPI\Persistence\Content\FieldValue Converts a $value to a persistence value.
validate ( eZ\Publish\API\Repository\Values\ContentType\FieldDefinition $fieldDefinition, eZ\Publish\SPI\FieldType\Value $value ) : eZ\Publish\SPI\FieldType\ValidationError[] Validates a field based on the validators in the field definition.
validateFieldSettings ( mixed $fieldSettings ) : eZ\Publish\SPI\FieldType\ValidationError[] Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.
validateValidatorConfiguration ( mixed $validatorConfiguration ) : eZ\Publish\SPI\FieldType\ValidationError[] Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.
validatorConfigurationFromHash ( array | hash | scalar | null $validatorConfigurationHash ) : mixed Converts the given $validatorConfigurationHash to a validator configuration of the type.
validatorConfigurationToHash ( mixed $validatorConfiguration ) : array | hash | scalar | null Converts the given $validatorConfiguration to a simple hash format.

Защищенные методы

Метод Описание
checkValueStructure ( Value $value ) Throws an exception if value structure is not of expected format.
checkValueType ( mixed $value ) Throws an exception if the given $value is not an instance of the supported value subtype.
createValueFromInput ( mixed $inputValue ) : mixed Inspects given $inputValue and potentially converts it into a dedicated value object.
getSortInfo ( Value $value ) : mixed Returns information for FieldValue->$sortKey relevant to the field type.

Описание методов

acceptValue() закрытый публичный метод

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()}.
final public acceptValue ( mixed $inputValue ) : Value
$inputValue mixed
Результат Value The potentially converted and structurally plausible value.

applyDefaultSettings() публичный метод

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.
public applyDefaultSettings ( mixed &$fieldSettings )
$fieldSettings mixed

applyDefaultValidatorConfiguration() публичный метод

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.
public applyDefaultValidatorConfiguration ( mixed &$validatorConfiguration )
$validatorConfiguration mixed

checkValueStructure() абстрактный защищенный метод

Note that this does not include validation after the rules from validators, but only plausibility checks for the general data format. This is an operation method for {@see \acceptValue()}. Example implementation: protected function checkValueStructure( Value $value ) { if ( !is_array( $value->cookies ) ) { throw new InvalidArgumentException( "An array of assorted cookies was expected." ); } }
abstract protected checkValueStructure ( Value $value )
$value Value

checkValueType() защищенный статический метод

This is an operation method for {@see \acceptValue()}. Default implementation expects the value class to reside in the same namespace as its FieldType class and is named "Value". Example implementation: static protected function checkValueType( $value ) { if ( !$inputValue instanceof \eZ\Publish\Core\FieldType\CookieJar\Value ) ) { throw new InvalidArgumentException( "Given value type is not supported." ); } }
protected static checkValueType ( mixed $value )
$value mixed A value returned by {@see \createValueFromInput()}.

createValueFromInput() абстрактный защищенный метод

If given $inputValue could not be converted or is already an instance of dedicate value object, the method should simply return it. This is an operation method for {@see \acceptValue()}. Example implementation: protected function createValueFromInput( $inputValue ) { if ( is_array( $inputValue ) ) { $inputValue = \eZ\Publish\Core\FieldType\CookieJar\Value( $inputValue ); } return $inputValue; }
abstract protected createValueFromInput ( mixed $inputValue ) : mixed
$inputValue mixed
Результат mixed The potentially converted input value.

fieldSettingsFromHash() публичный метод

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.
public fieldSettingsFromHash ( array | hash | scalar | null $fieldSettingsHash ) : mixed
$fieldSettingsHash array | hash | scalar | null
Результат mixed

fieldSettingsToHash() публичный метод

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.
public fieldSettingsToHash ( mixed $fieldSettings ) : array | hash | scalar | null
$fieldSettings mixed
Результат array | hash | scalar | null

fromPersistenceValue() публичный метод

Converts a persistence $fieldValue to a Value.
public fromPersistenceValue ( eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue ) : Value
$fieldValue eZ\Publish\SPI\Persistence\Content\FieldValue
Результат Value

getRelations() публичный метод

Not intended for \eZ\Publish\API\Repository\Values\Content\Relation::COMMON type relations, there is an API for handling those.
public getRelations ( eZ\Publish\SPI\FieldType\Value $fieldValue ) : array
$fieldValue eZ\Publish\SPI\FieldType\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 ) )

getSettingsSchema() публичный метод

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.
public getSettingsSchema ( ) : mixed
Результат mixed

getSortInfo() защищенный метод

Return value is mixed. It should be something which is sensible for sorting. It is up to the persistence implementation to handle those values. Common string and integer values are safe. For the legacy storage it is up to the field converters to set this value in either sort_key_string or sort_key_int.
protected getSortInfo ( Value $value ) : mixed
$value Value
Результат mixed

getValidatorConfigurationSchema() публичный метод

Returns a schema for the validator configuration expected by the FieldType.
См. также: 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). array( 'stringLength' => array( 'minStringLength' => array( 'type' => 'int', 'default' => 0, ), 'maxStringLength' => array( 'type' => 'int' 'default' => null, ) ), );
public getValidatorConfigurationSchema ( ) : mixed
Результат mixed

isEmptyValue() публичный метод

Default implementation, which performs a "==" check with the value returned by {@link getEmptyValue()}. Overwrite in the specific field type, if necessary.
public isEmptyValue ( eZ\Publish\SPI\FieldType\Value $value ) : boolean
$value eZ\Publish\SPI\FieldType\Value
Результат boolean

isSearchable() публичный метод

Returns whether the field type is searchable.
public isSearchable ( ) : boolean
Результат boolean

isSingular() публичный метод

Indicates if the field definition of this type can appear only once in the same ContentType.
public isSingular ( ) : boolean
Результат boolean

onlyEmptyInstance() публичный метод

Indicates if the field definition of this type can be added to a ContentType with Content instances.
public onlyEmptyInstance ( ) : boolean
Результат boolean

setTransformationProcessor() публичный метод

public setTransformationProcessor ( TransformationProcessor $transformationProcessor )
$transformationProcessor eZ\Publish\Core\Persistence\TransformationProcessor

toPersistenceValue() публичный метод

Converts a $value to a persistence value.
public toPersistenceValue ( eZ\Publish\SPI\FieldType\Value $value ) : eZ\Publish\SPI\Persistence\Content\FieldValue
$value eZ\Publish\SPI\FieldType\Value
Результат eZ\Publish\SPI\Persistence\Content\FieldValue

validate() публичный метод

This is a base implementation, returning an empty array() that indicates that no validation errors occurred. Overwrite in derived types, if validation is supported.
public validate ( eZ\Publish\API\Repository\Values\ContentType\FieldDefinition $fieldDefinition, eZ\Publish\SPI\FieldType\Value $value ) : eZ\Publish\SPI\FieldType\ValidationError[]
$fieldDefinition eZ\Publish\API\Repository\Values\ContentType\FieldDefinition The field definition of the field
$value eZ\Publish\SPI\FieldType\Value The field value for which an action is performed
Результат eZ\Publish\SPI\FieldType\ValidationError[]

validateFieldSettings() публичный метод

This method expects that given $fieldSettings are complete, for this purpose method {@link self::applyDefaultSettings()} is provided.
public validateFieldSettings ( mixed $fieldSettings ) : eZ\Publish\SPI\FieldType\ValidationError[]
$fieldSettings mixed
Результат eZ\Publish\SPI\FieldType\ValidationError[]

validateValidatorConfiguration() публичный метод

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.
public validateValidatorConfiguration ( mixed $validatorConfiguration ) : eZ\Publish\SPI\FieldType\ValidationError[]
$validatorConfiguration mixed
Результат eZ\Publish\SPI\FieldType\ValidationError[]

validatorConfigurationFromHash() публичный метод

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.
public validatorConfigurationFromHash ( array | hash | scalar | null $validatorConfigurationHash ) : mixed
$validatorConfigurationHash array | hash | scalar | null
Результат mixed

validatorConfigurationToHash() публичный метод

Default implementation, which just returns the given $validatorConfiguration, which is by convention an array for all internal field types. Overwrite this method, if necessary.
public validatorConfigurationToHash ( mixed $validatorConfiguration ) : array | hash | scalar | null
$validatorConfiguration mixed
Результат array | hash | scalar | null

Описание свойств

$settingsSchema защищенное свойство

The key is the setting name, and the value is the default value for given setting, set to null if no particular default should be set.
protected mixed $settingsSchema
Результат mixed

$transformationProcessor защищенное свойство

String transformation processor, used to normalize sort string as needed.
protected TransformationProcessor,eZ\Publish\Core\Persistence $transformationProcessor
Результат eZ\Publish\Core\Persistence\TransformationProcessor

$validatorConfigurationSchema защищенное свойство

This is a base implementation, containing an empty array() that indicates that no validators are supported. Overwrite in derived types, if validation is supported.
См. также: getValidatorConfigurationSchema()
protected mixed $validatorConfigurationSchema
Результат mixed