public function getItemFromIri(string $iri, array $context = [])
{
try {
$parameters = $this->router->match($iri);
} catch (RoutingExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('No route matches "%s".', $iri), $e->getCode(), $e);
}
if (!isset($parameters['_api_resource_class'], $parameters['id'])) {
throw new InvalidArgumentException(sprintf('No resource associated to "%s".', $iri));
}
if ($item = $this->itemDataProvider->getItem($parameters['_api_resource_class'], $parameters['id'], null, $context)) {
return $item;
}
throw new InvalidArgumentException(sprintf('Item not found for "%s".', $iri));
}