Adding Object Datatypes
With plugins, it is also possible to add individual data types for Pimcore Objects. Following steps are necessary to do so:
-
Create a PHP class for server-side implementation: This class needs to extend
Pimcore\Model\DataObject\ClassDefinition\Dataand defines how your data type is stored into database, how the getters and setters for Pimcore objects are generated and how data is sent to and read from Pimcore Admin UI.For examples have a look at the Pimcore core datatypes at github.
-
Create JavaScript class for Class Definition editor (object data): This JavaScript class defines the representation of the data type in the Class Definition editor and therefore where it is allowed (object, objectbricks, fieldcollections, localizedfields), its group, its label, its icon and its config options in class editor.
It needs to extend
pimcore.object.classes.data.data, be located in namespacepimcore.object.classes.dataand named after the$fieldtypeproperty of the corresponding PHP class.For examples have a look at the Pimcore core datatypes at
github -
Create JavaScript class for object editor (object tag): This JavaScript class defines the representation of the data type in the object editor and therefore defines how data is presented and an can be entered within Pimcore objects.
It needs to extend
pimcore.object.tags.abstract, be located in namespacepimcore.object.tagsand named after the$fieldtypeproperty of the corresponding PHP class.For examples have a look at the Pimcore core datatypes at
github -
Register a datatype in Pimcore Register a datatype in Pimcore by extending the
pimcore.objects.class_definitions.data.mapconfiguration. This can be done in any config file which is loaded (e.g.config/config.yaml), but if you provide the datatype with a bundle you should define it in a configuration file which is automatically loaded.Example:
# config/config.yaml
pimcore:
objects:
class_definitions:
data:
map:
myDataType: \App\Model\DataObject\Data\MyDataType