-
Notifications
You must be signed in to change notification settings - Fork 2
Data Handler for Doctrine
The doctrine data handler is just an enhanced version of the Data Handler that you should use when your subject objects are doctrine entities.
The handler is used exactly like the DataHandler, but it receive an entity manager in the constructor for two main porpouses.
-
Handling data types. For example a DateTime property could be detected and casted before calling the setter
-
hydrating related objects. For example if you have a user that should be patched to change it's group, and the group is a ManyToOne property of the entity, you could do something like:
PATCH /users/1
{ "op": "data", "property": "group", "value": "3" }
With the normal data handler you will get an error, because doctrine expects the argument of setGroup to be an instance of the Group entity. The Doctrine data handler is able to detect that the property is a relation, query the database for the group object, hydrate it and call the method with the correct argument.
If you are using Doctrine, and you are patching entities use the doctrine data handler instead of the simple data handler
Use the table of contents to the top right to navigate to other wiki sections.