-
-
Notifications
You must be signed in to change notification settings - Fork 908
[Subresource] Fixed the serialization context builder #1617
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
Conversation
@@ -111,6 +111,8 @@ public function load($data, $type = null): RouteCollection | |||
'property' => $operation['property'], | |||
'identifiers' => $operation['identifiers'], | |||
'collection' => $operation['collection'], | |||
'parent_resource_class' => $resourceClass, |
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.
We can't say that it's the "parent" because there can be an "infinity" IMO.
Anyway, we need to discuss here is whether we take the "Root" as the metadata entrypoint or the "Queue" (last).
Explanation:
/foo/1/bars/2
This path will get you an entity of type Bar
. When this is serialized, where should we look to get the normalization_context
?
Bar
metadata, after all this is aBar
responseFoo
metadata, because it's a subresource
We need to choose one. At the moment, IIRC the code looks on the Bar
metadata to find the normalization_context
for the given operation.
If we want to take the "Root" (because this is where we declared the subresource), I don't think that you need the "parent_resource_class".
Take a look at the SubresourceOperationFactory:
$rootClass = $identifiers[0][1]
is where you want to look at.
the operation_name
should be the correct one IMO
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.
I vote for:
Foo metadata, because it's a subresource
$rootClass = $identifiers[0][1] is where you want to look at.
yes I noticed that. But I thought it was risky to use that ;)
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 I noticed that. But I thought it was risky to use that ;)
It is not and it's meant for that ;)
Anyway I think there are edge cases that may be hard to cover. I haven't slept enough to give a more detailled though on this haha but I'll think about it. |
No problem. But for now (and for me) the subresource system is not usable yet :/ as I can not control what the API returns. |
So what do you think of this ? Is it the right approach? |
Having the Though, you don't need |
Sure. I will update the pr according to |
Closing in favor of #2706 |
Before going further, I would like to know if this is the right direction.