Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Skip to end of metadata
Go to start of metadata

At this point, we have an “anonymous” Symfony 2 bundle. 

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 ezpublish-kernel (in vendor/ezsystems), in the eZ/Publish/Core/FieldType folder. Each FieldType has its own subfolder: TextLine, Email, Url… we will use a structure quite close from this.

 From the tutorial repository, list the contents of the eZ/Publish/FieldType folder:

 eZ
└── Publish
   └── FieldType
       └── Tweet
           ├── Type.php
           └── Value.php

We have the two base classes required by a FieldType: Type and Value.

The Type class

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