fix: handle item iri with identifiers in LegacyIriConverter #5670
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.
Hello, a small fix for when using the
\ApiPlatform\Core\Api\LegacyIriConverter
The Problem:
#5630 Introduced a nice way to fix the IriConverterInterface deprecation before turning off the
metadata_backward_compatibility_layer
.One issue I ran into is that
LegacyIriConverter::getIriFromResource
decides if the iri will be Item level or Collection level solely based on if the given$item
parameter is a string vs an object.With this methodology, I would have instantiate a new object just to trigger the Item level iri conversion.
(To compare, The new IriConverterInterface handles this decision smartly, using the metadata of the Operation and the given Object).
Proposed solution
Previously, the old IriConverterInterface had 2 distinct methods to split this (
getItemIriFromResourceClass
andgetIriFromResourceClass
)— the only difference being an extra parameterarray $identifiers
.This adds back the ability to identify a Resource based on className + identifiers.