-
-
Notifications
You must be signed in to change notification settings - Fork 940
Fix serialization when using interface as resource #2822
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
Fix serialization when using interface as resource #2822
Conversation
| $propertyMetadata = $this->transformLinkStatus($propertyMetadata, $normalizationGroups, $denormalizationGroups); | ||
| } catch (ResourceClassNotFoundException $e) { | ||
| // No need to check link status if related class is not a resource | ||
| // hack to allow non-resource classes (actually they should not be supported) |
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.
If this hack is removed, all hell breaks loose, because we're using the PropertyMetadataFactory for input/output classes (DTOs). 😞
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 we done it on purpose. It's a good move actually, it allows to retrieve the shape of any PHP structure, regardless if it is mapped with @ApiResource or not.
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.
Okay, I'll update the comment. 😎
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.
But actually, I can see many problems with using the property metadata system like this. It's simply not designed for non-resources, as you can see here. It'd give the wrong results (as in this case), which is arguably worse than not using it at all.
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.
1071f97 to
075222c
Compare
075222c to
731b45f
Compare
731b45f to
a3fd33c
Compare
8330e42 to
8b5b129
Compare
8b5b129 to
f8e3011
Compare
f8e3011 to
50221f5
Compare
| $this->resourceMetadataFactory = $resourceMetadataFactory; | ||
| $this->serializerClassMetadataFactory = $serializerClassMetadataFactory; | ||
| $this->decorated = $decorated; | ||
| $this->resourceClassResolver = $resourceClassResolver; |
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.
Deprecated if null?
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.
Hmm... We need to do this in many places. Will do this in a follow-up PR?
50221f5 to
7bdb0f6
Compare
|
Build failures should be fixed by #2841 We shall re-trigger the build after that's merged. |
7bdb0f6 to
6a64d36
Compare
|
Build still failing, will be fixed by #2843 |
6a64d36 to
bba7e32
Compare
bba7e32 to
c9d9c58
Compare
|
nice :D @Nek- will be happy with this :D |
|
this has caused a regression for me and I can't seem to fix I have an operation which returns a different class to resources the operation is defined on. |
|
@bendavies Can you open an issue? |
|
@teohhanhui done. |
TODO: