You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see, the context passed to $this->iriConverter->getIriFromResource() (4th parameter) is hardcoded and always refers to the ID of the current denormalizing entity.
This is not correct (and, in fact, there is also the todo to remember this fact) as this could break the code.
Aerendir
changed the title
Fix #5545.
Guess uri variables with the operation and the data instead of hardcoding id
Apr 15, 2023
Aerendir
changed the title
Guess uri variables with the operation and the data instead of hardcoding id
feat: Guess uri variables with the operation and the data instead of hardcoding id
Apr 15, 2023
Aerendir
changed the title
feat: Guess uri variables with the operation and the data instead of hardcoding id
fix(serializer): Guess uri variables with the operation and the data instead of hardcoding id
Apr 15, 2023
Aerendir
changed the title
fix(serializer): Guess uri variables with the operation and the data instead of hardcoding id
fix(serializer): guess uri variables with the operation and the data instead of hardcoding id (#5545)
Apr 15, 2023
Aerendir
changed the title
fix(serializer): guess uri variables with the operation and the data instead of hardcoding id (#5545)
fix(serializer): Guess uri variables with the operation and the data instead of hardcoding id
Apr 15, 2023
Thanks! Can you document this an provide an example in the official docs? It's been something I've wanted and worked with subresources in 2.6 but much harder to do in 3.0, in part because there's so few examples.
This PR simply allows to use an URI like /companies/{companyId}/employees/{employeeId} while before you were forced to use one like /companies/{companyId}/employees/{id} (like in the example provided in the link).
Well we're back on this as this can not work, I should've been more careful but this is not how things are supposed to work. Use IRIs or a custom normalizer if you need to do weird stuff.
This file contains hidden or 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
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.
mainIn a situation where these two conditions are true, also alternatively and not necessarily at the same time, the code will break:
account/{account}/resource/{resource}/sub_resource/{sub_resource}id(in the above example, the uri parameter issub_resource)Why it breaks
In
ItemNormalizer:79there is this todo:core/src/Serializer/ItemNormalizer.php
Lines 79 to 80 in ccef472
As you can see, the context passed to
$this->iriConverter->getIriFromResource()(4th parameter) is hardcoded and always refers to the ID of the current denormalizing entity.This is not correct (and, in fact, there is also the todo to remember this fact) as this could break the code.