-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypedFieldMapper for automatic mapping of typed PHP fields to DBAL types #10313
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
michnovka
force-pushed
the
2.14.x-typed-field-mapper
branch
from
December 16, 2022 17:16
53cef37
to
657f376
Compare
greg0ire
previously approved these changes
Dec 16, 2022
greg0ire
reviewed
Dec 16, 2022
derrabus
requested changes
Dec 16, 2022
…L types Previously, only a predefined set of automatic mappings was allowed, such as int, float, boolean, DateTime etc. With this extension, it is possible to supply custom TypedFieldMapper implementation which takes 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 DefaultTypedFieldMapper which is used by default when no mapper is supplied. The selected TypedFieldMapper is passed into ClassMetadataInfo constructor. If empty, the DefaultTypedFieldMapper is used. There is also ChainTypedFieldMapper class which allows chaining multiple TypedFieldMappers and 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).
michnovka
force-pushed
the
2.14.x-typed-field-mapper
branch
from
December 17, 2022 00:24
1352254
to
7dcb513
Compare
greg0ire
approved these changes
Dec 17, 2022
beberlei
approved these changes
Dec 17, 2022
derrabus
approved these changes
Dec 18, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
derrabus
added a commit
to derrabus/orm
that referenced
this pull request
Dec 19, 2022
* 2.14.x: Drop forceful loading of annotations (doctrine#10321) Document stdClass structures used by CommitOrderCalculator (doctrine#10315) Psalm 5.3.0 (doctrine#10317) PHPStan 1.9.4 (doctrine#10318) add apcu enabled check if apcu extension loaded (doctrine#10310) (doctrine#10311) Add TypedFieldMapper for automatic mapping of typed PHP fields to DBAL types (doctrine#10313)
derrabus
added a commit
to derrabus/orm
that referenced
this pull request
Dec 19, 2022
* 2.14.x: Drop forceful loading of annotations (doctrine#10321) Document stdClass structures used by CommitOrderCalculator (doctrine#10315) Psalm 5.3.0 (doctrine#10317) PHPStan 1.9.4 (doctrine#10318) add apcu enabled check if apcu extension loaded (doctrine#10310) (doctrine#10311) Add TypedFieldMapper for automatic mapping of typed PHP fields to DBAL types (doctrine#10313)
n-e-m-a-nj-a
pushed a commit
to n-e-m-a-nj-a/orm
that referenced
this pull request
Jan 27, 2023
…L types (doctrine#10313) Previously, only a predefined set of automatic mappings was allowed, such as int, float, boolean, DateTime etc. With this extension, it is possible to supply custom TypedFieldMapper implementation which takes 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 DefaultTypedFieldMapper which is used by default when no mapper is supplied. The selected TypedFieldMapper is passed into ClassMetadataInfo constructor. If empty, the DefaultTypedFieldMapper is used. There is also ChainTypedFieldMapper class which allows chaining multiple TypedFieldMappers and 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).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative implementation of #10290, fixes #9561
Previously, only a predefined set of automatic mappings was allowed for as
array
,bool
,int
,float
,string
,DateTime
,DateTimeImmutable
andDateInterval
.With this extension, it is possible to supply custom
TypedFieldMapper
implementation. ItsvalidateAndComplete
takes 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
DefaultTypedFieldMapper
which is used by default when no mapper is supplied.The selected
TypedFieldMapper
is passed intoClassMetadataInfo
's constructor. If empty, theDefaultTypedFieldMapper
is used.There is also
ChainTypedFieldMapper
class which allows chaining multipleTypedFieldMappers
and 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
ClassMetadataInfo
and all mapping drivers.