eZPublishCommunityProject  2012.12
eZ\Publish\Core\FieldType\FieldType Class Reference

Base class for field types, the most basic storage unit of data inside eZ Publish. More...

+ Inheritance diagram for eZ\Publish\Core\FieldType\FieldType:
+ Collaboration diagram for eZ\Publish\Core\FieldType\FieldType:

Public Member Functions

 acceptValue ($inputValue)
 Potentially builds and checks the type and structure of the $inputValue. More...
 
 fieldSettingsFromHash ($fieldSettingsHash)
 Converts the given $fieldSettingsHash to field settings of the type. More...
 
 fieldSettingsToHash ($fieldSettings)
 Converts the given $fieldSettings to a simple hash format. More...
 
 fromPersistenceValue (FieldValue $fieldValue)
 Converts a persistence $fieldValue to a Value. More...
 
 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...
 
 isEmptyValue ($value)
 Returns if the given $value is considered empty by the field type. More...
 
 isSearchable ()
 Returns whether the field type is searchable. More...
 
 toPersistenceValue ($value)
 Converts a $value to a persistence value. More...
 
 validate (FieldDefinition $fieldDefinition, $fieldValue)
 Validates a field based on the validators in the field definition. More...
 
 validateFieldSettings ($fieldSettings)
 Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct. More...
 
 validateValidatorConfiguration ($validatorConfiguration)
 Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct. More...
 
 validatorConfigurationFromHash ($validatorConfigurationHash)
 Converts the given $validatorConfigurationHash to a validator configuration of the type. More...
 
 validatorConfigurationToHash ($validatorConfiguration)
 Converts the given $validatorConfiguration to a simple hash format. More...
 
- Public Member Functions inherited from eZ\Publish\API\Repository\FieldType
 fromHash ($hash)
 Converts an $hash to the Value defined by the field type. More...
 
 getEmptyValue ()
 Returns the empty value for this field type. More...
 
 getFieldTypeIdentifier ()
 Returns the field type identifier for this field type. More...
 
 getName ($value)
 Returns a human readable string representation from the given $value. More...
 
 toHash ($value)
 Converts the given $value into a plain hash format. More...
 

Protected Member Functions

 getSortInfo ($value)
 Returns information for FieldValue->$sortKey relevant to the field type. More...
 
 internalAcceptValue ($inputValue)
 Implements the core of {. More...
 

Protected Attributes

 $settingsSchema = array()
 
 $validatorConfigurationSchema = array()
 

Detailed Description

Base class for field types, the most basic storage unit of data inside eZ Publish.

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.

Member Function Documentation

eZ\Publish\Core\FieldType\FieldType::acceptValue (   $inputValue)
final

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 getEmptyValue().

Exceptions
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the parameter is not of the supported value sub type
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the value does not match the expected structure
Parameters
mixed$inputValue
Returns
The potentially converted and structurally plausible value.

Referenced by eZ\Publish\Core\FieldType\User\Type\fromPersistenceValue(), eZ\Publish\Core\FieldType\Checkbox\Type\getName(), eZ\Publish\Core\FieldType\Keyword\Type\getName(), eZ\Publish\Core\FieldType\MapLocation\Type\getName(), eZ\Publish\Core\FieldType\Url\Type\getName(), eZ\Publish\Core\FieldType\Author\Type\getName(), eZ\Publish\Core\FieldType\User\Type\getName(), eZ\Publish\Core\FieldType\Image\Type\getName(), eZ\Publish\Core\FieldType\XmlText\Type\getName(), eZ\Publish\Core\FieldType\Null\Type\getName(), eZ\Publish\Core\FieldType\BinaryBase\Type\getName(), eZ\Publish\Core\FieldType\EmailAddress\Type\getName(), eZ\Publish\Core\FieldType\Integer\Type\getName(), and eZ\Publish\Core\FieldType\Float\Type\getName().

eZ\Publish\Core\FieldType\FieldType::fieldSettingsFromHash (   $fieldSettingsHash)

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

This is the reverse operation of 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
Returns
mixed

Implements eZ\Publish\API\Repository\FieldType.

eZ\Publish\Core\FieldType\FieldType::fieldSettingsToHash (   $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
Returns
array|hash|scalar|null

Implements eZ\Publish\API\Repository\FieldType.

eZ\Publish\Core\FieldType\FieldType::fromPersistenceValue ( FieldValue  $fieldValue)

Converts a persistence $fieldValue to a Value.

Parameters
\eZ\Publish\SPI\Persistence\Content\FieldValue$fieldValue
Returns
mixed
eZ\Publish\Core\FieldType\FieldType::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.

Returns
mixed

Implements eZ\Publish\API\Repository\FieldType.

eZ\Publish\Core\FieldType\FieldType::getSortInfo (   $value)
protected

Returns information for FieldValue->$sortKey relevant to the field type.

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.

Parameters
mixed$value
Returns
mixed

Referenced by eZ\Publish\Core\FieldType\FieldType\toPersistenceValue().

eZ\Publish\Core\FieldType\FieldType::getValidatorConfigurationSchema ( )

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

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).

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

Returns
mixed

Implements eZ\Publish\API\Repository\FieldType.

eZ\Publish\Core\FieldType\FieldType::internalAcceptValue (   $inputValue)
abstractprotected

Implements the core of {.

See Also
acceptValue()}.
Parameters
mixed$inputValue
Returns
The potentially converted and structurally plausible value.

Referenced by eZ\Publish\Core\FieldType\FieldType\acceptValue().

eZ\Publish\Core\FieldType\FieldType::isEmptyValue (   $value)

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

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

Parameters
mixed$value
Returns
boolean

Referenced by eZ\Publish\Core\FieldType\User\Type\toHash(), eZ\Publish\Core\FieldType\Page\Type\toHash(), eZ\Publish\Core\FieldType\Url\Type\toHash(), eZ\Publish\Core\FieldType\DateAndTime\Type\toHash(), eZ\Publish\Core\FieldType\EmailAddress\Type\toHash(), eZ\Publish\Core\FieldType\BinaryBase\Type\toHash(), and eZ\Publish\Core\FieldType\Country\Type\toHash().

eZ\Publish\Core\FieldType\FieldType::isSearchable ( )

Returns whether the field type is searchable.

Returns
boolean

Implements eZ\Publish\API\Repository\FieldType.

eZ\Publish\Core\FieldType\FieldType::toPersistenceValue (   $value)

Converts a $value to a persistence value.

Parameters
mixed$value
Returns
eZ\Publish\Core\FieldType\FieldType::validate ( FieldDefinition  $fieldDefinition,
  $fieldValue 
)

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.

Exceptions
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
Parameters
\eZ\Publish\API\Repository\Values\ContentType\FieldDefinition$fieldDefinitionThe field definition of the field
\eZ\Publish\Core\FieldType\Value$fieldValueThe field for which an action is performed
Returns
[]
eZ\Publish\Core\FieldType\FieldType::validateFieldSettings (   $fieldSettings)

Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

Parameters
mixed$fieldSettings
Returns
[]
eZ\Publish\Core\FieldType\FieldType::validateValidatorConfiguration (   $validatorConfiguration)

Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

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
Returns
[]
eZ\Publish\Core\FieldType\FieldType::validatorConfigurationFromHash (   $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
Returns
mixed

Implements eZ\Publish\API\Repository\FieldType.

eZ\Publish\Core\FieldType\FieldType::validatorConfigurationToHash (   $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
Returns
array|hash|scalar|null

Implements eZ\Publish\API\Repository\FieldType.

Member Data Documentation

eZ\Publish\Core\FieldType\FieldType::$settingsSchema = array()
protected
eZ\Publish\Core\FieldType\FieldType::$validatorConfigurationSchema = array()
protected

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