Step 1 - Implement the Point 2D Value class¶
You can find all files used and modified in this step on GitHub.
To start the tutorial, you need to make a clean eZ Platform installation.
Follow the guide for your system to install eZ Platform,
configure a server,
and start the web server.
Remember to install using the
Open your project with a clean installation and create the base directory for a new Point 2D Field Type in
The Value class¶
The Value class of a Field Type is by design very simple. It is used to represent an instance of the Field Type within a Content item. Each Field presents its data using an instance of the Type's Value class. For more information about Field Type Value, see Value handling.
According to the convention, the class representing Field Type Value should be named
Value and should be placed in the same namespace as the Type definition.
The Point 2D Value class will contain:
- private properties, used to store the actual data
- an implementation of the
__toString()method, required by the Value interface
By default, the constructor from
FieldType\Value will be used.
The Point 2D is going to store two elements (coordinates for point 2D):
At this point, it does not matter where they are stored. You want to focus on what the Field Type exposes as an API.
src/FieldType/Point2D/Value.php should have the following properties:
1 2 3 4 5 6 7 8
A Value class must also implement the
To match the
FieldType\Value interface, you need to implement
You also need to add getters and setters for
This class will represent the point 2D.
The final code should look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40