...
The eZ Publish CMS can support arbitrary data to be stored in the fields of a content objectitem. In order to support custom data, besides the standard data types, a developer needs to create a custom FieldType.
...
Storing external data
A FieldType
may store arbitrary data in external data sources and is in fact encouraged to do so. External storages can be e.g. a web service, a file in the file system, another database or even the eZ Publish database itself (in form of a non-standard table). In order to perform this task, the FieldType
will interact with the Persistence SPI, which can be found in eZ\Publish\SPI\Persistence
, through the eZ\Publish\SPI\FieldType\FieldStorage
interface.
Whenever the internal storage of a Content item that includes a Field of the FieldType
is accessed, one of the following methods is called to also access the external data:
hasFieldData()
Returns if the FieldType
stores extrnal data at all.
storeFieldData()
Called right before a Field
of FieldType
is stored. The method should perform the storing of $externalData
. The method must return true
, if the call manipulated internal data of the given Field
, so that it is updated in the internal database.
getFieldData()
Is called after a Field
has been restored from the database in order to restore $externalData
.
deleteFieldData()
Must delete external data for the given Field
, if exists.
getIndexData()
See search service
Each of the above methods receive a $context array, which contains information on the underlying storage and the environment. This context can be used to store data in the eZ Publish data storage, but outside of the normal structures (e.g. a custom table in an SQL database). Note that the FieldType must take care on it's own for being compliant to different data sources and that 3rd parties can extend the data source support easily. For more information about this, take a look at the Best practices section.
...