Let’s start by creating the structure for our FieldType. To make it easier to move around the code, we will mimic to some extent the structure that is used in the kernel. Native FieldTypes are located inside
vendor/ezsystems), in the
eZ/Publish/Core/FieldType folder. Each FieldType has its own subfolder:
Url… we will use a structure quite close from this.
From the tutorial repository, list the contents of the
We have the two base classes required by a FieldType:
The Type contains the logic of the field type: validating data, transforming from various formats, describing the validators…
A type class must implement
eZ\Publish\SPI\FieldType\FieldType. It may also extend the
eZ\Publish\Core\FieldType\FieldType abstract class.
The Value is used to represent an instance of our type within a Content item. Each Field will present its data using an instance of the Type’s Value class.
A value class must implement the
eZ\Publish\SPI\FieldType\Value interface. It may also extend the
eZ\Publish\Core\FieldType\Value abstract class.