June 2017
Intermediate to advanced
394 pages
8h 52m
English
Another option is to handle the Value Object persistence using a Doctrine Custom Type. A Custom Type adds a new mapping type to Doctrine — one that describes a custom transformation between an Entity field and the database representation, in order to persist the former.
As the Doctrine DBAL 2 Documentation explains:
Just redefining how database types are mapped to all the existing Doctrine types is not at all that useful. You can define your own Doctrine Mapping Types by extending Doctrine\DBAL\Types\Type. You are required to implement 4 different methods to get this working.
With the object type, the serialization step includes information, such as the class, that makes it quite difficult to safely refactor our code. ...