diff --git a/src/Core/Api/LegacyIriConverter.php b/src/Core/Api/LegacyIriConverter.php index c2bb70be565..c56bed64667 100644 --- a/src/Core/Api/LegacyIriConverter.php +++ b/src/Core/Api/LegacyIriConverter.php @@ -16,6 +16,7 @@ use ApiPlatform\Api\IriConverterInterface; use ApiPlatform\Api\UrlGeneratorInterface; use ApiPlatform\Core\Api\IriConverterInterface as LegacyIriConverterInterface; +use ApiPlatform\Exception\InvalidArgumentException; use ApiPlatform\Metadata\Operation; /** @@ -64,6 +65,14 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation public function getIriFromResource($item, int $referenceType = UrlGeneratorInterface::ABS_PATH, Operation $operation = null, array $context = []): ?string { if (null === $this->iriConverter) { + if ($identifiers = ($context['uri_variables'] ?? null)) { + try { + return $this->legacyIriConverter->getItemIriFromResourceClass($item, $identifiers, $referenceType); + } + catch (InvalidArgumentException $e) { + } + } + return \is_string($item) ? $this->legacyIriConverter->getIriFromResourceClass($item, $referenceType) : $this->legacyIriConverter->getIriFromItem($item, $referenceType); }