mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10313] Add TypedFieldMapper for automatic mapping of typed PHP fields to DBAL types #12266
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10313
State: closed
Merged: Yes
This is an alternative implementation of https://github.com/doctrine/orm/pull/10290, fixes https://github.com/doctrine/orm/issues/9561
Previously, only a predefined set of automatic mappings was allowed for as
array,bool,int,float,string,DateTime,DateTimeImmutableandDateInterval.With this extension, it is possible to supply custom
TypedFieldMapperimplementation. ItsvalidateAndCompletetakes as parameter the ReflectionProperty of a given field and decides the appropriate mapping.A new configuration option was added to set and get the
TypedFieldMapper.The old logic was moved into a class
DefaultTypedFieldMapperwhich is used by default when no mapper is supplied.The selected
TypedFieldMapperis passed intoClassMetadataInfo's constructor. If empty, theDefaultTypedFieldMapperis used.There is also
ChainTypedFieldMapperclass which allows chaining multipleTypedFieldMappersand apply them in a cascade (always if a field gets type assigned by the earlier mapper in the list, it will not be changed later).Documentation has been updated to explain the new features. Tests were added to cover the new classes as well as
ClassMetadataInfoand all mapping drivers.