eZecosystem / Mirror / doc.ez.no / eZ Platform Developer Documentation / Structure the bundle

Structure the bundle

Page edited by Sarah Haïm-Lubczanski - "Adding a note about the github repository of the tutorial"

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

Let’s start by creating the structure for our Field Type. To make it easier to move around the code, we will to some extent mimic the structure that is used in the kernel. Native Field Types are located inside ezpublish-kernel (in vendor/ezsystems), in the eZ/Publish/Core/FieldType folder. Each Field Type has its own subfolder: TextLine, Email, Url, etc. We will use a structure quite close to this.

Clone the Github repository to follow this tutorial, it will be usefu: https://github.com/ezsystems/TweetFieldTypeBundle

 

From the tutorial git 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 Field Type: Type and Value.

The Type class

The Type contains the logic of the Field Type: validating data, transforming from various formats, describing the validators, etc.
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.

Tutorial path