Step 1 - Implement the Point 2D Value class¶
To start the tutorial, you need to make a clean Ibexa DXP installation.
Follow the guide for your system to install Ibexa DXP,
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.
Simple hash values
A simple hash value always means an array of scalar values and/or nested arrays of scalar values. To avoid issues with format conversion, don't use objects inside the simple hash values.
The Point 2D Value class contains:
- 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 is 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
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 represents 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 41 42 43 44 45 46