-
-
Notifications
You must be signed in to change notification settings - Fork 340
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
[Autocomplete] Add support for doctrine/orm:^3.0 #1468
Conversation
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.
Thanks for getting this going - I think I answered the pending questions
ed63e1a
to
6d83ca9
Compare
// In doctrine/orm:^3.0; $metadata will be a FieldMapping object | ||
if (!\is_array($metadata)) { | ||
return (array) $metadata; | ||
} |
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.
For ORM 3, won't this return [0 => FieldMapping]
? But in 2.9, it would be an associative array containing the metadata? Or am I misunderstanding?
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.
Yes in ORM 3, the ClassMetaData::$fieldMappings
is of type array<string, FieldMapping>
(see) and in ORM 2 it's just an array
(mixed
in docs, see), it's been defined as a psalm-type
(see), that may cause the confusion?
Since we access the ClassMetaData::$fieldMappings
with a 'key' it will return a FieldMapping
object directly and casting it to an array works for the FieldMapping
object as it is defined using public properties.
ab71ae5
to
81b4807
Compare
Thanks for reviewing Ryan and Simon! Sorry for the late response, but the flu hit me and my little one got the chickenpox, it was a messy week 😅 |
81b4807
to
20f4dad
Compare
Thanks Evert! We'll test on ORM 3 when Foundry adds support |
Thank you for this, and i hope everything is better now for you & familly 😃 |
Follow up on #1459 as it seemed a bit more complicated :)
Because in the current
getPropertyMetadata
function, see and below:The function combines getting metadata from
fieldMappings
andassociationMappings
, that both return anarray
in Doctrine ORM 2.This however changes in Doctrine ORM 3 in
fieldMappings
returning aFieldMapping
object andassociationMappings
in anAssociationMapping
object.To support both Doctrine ORM 2 and 3, I didn't changed the return type of the function for now, as we would otherwise need to bump the major version for the
Autocomplete
component.To ease the transition to Doctrine ORM 3 in the future, I've splitted
getPropertyMetadata
ingetFieldMetadata
andgetAssociationMetadata
.TODO
getPropertyMetadata()
function as a proxy to the new methods? (I removed it for now as the method shouldn't be used directly as mentioned.@internal
thesrc/Autocomplete/src/Doctrine/EntityMetadata.php
class also (as mentioned)?doctrine/orm
3 zenstruck/foundry#556