[RFC] Expose resource in processor context #7431
Closed
+8
−2
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.
When writing a route with a custom input like
with an input like
I didn't find an easy way to access to the User resource (in order to modify it), resolved by the URL.
The
$context['previous_data']
doesn't fulfill this job because it's a cloned data so if we try to modify/flush the data it does nothing and if we try to modify/persist/flush the data we get an EntityCollision error with doctrine.The data request attribute coming from the ReadProvider is later overridden by the DeserializeListener which are generating the Input. Too bad API platform doesn't keep a reference to this resource somewhere no ?
I would save an extra query in the processor
So what about adding a
resource
key in the request/context ?When trying locally it works for me with the ReadProvider + WriteListener changes, but I dunno if
Also, you might want to challenge the naming.