From 50085de29a91784cf8f24da5c218212141f82689 Mon Sep 17 00:00:00 2001 From: Kai Grassnick Date: Fri, 6 Sep 2024 11:05:36 +0200 Subject: [PATCH] fix(linkshandler): resource_class from context instead of entity class --- src/Doctrine/Common/State/PersistProcessor.php | 2 +- src/Doctrine/Odm/State/LinksHandlerTrait.php | 2 +- src/Doctrine/Orm/State/LinksHandlerTrait.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Doctrine/Common/State/PersistProcessor.php b/src/Doctrine/Common/State/PersistProcessor.php index 20e93ac439..30ceb35774 100644 --- a/src/Doctrine/Common/State/PersistProcessor.php +++ b/src/Doctrine/Common/State/PersistProcessor.php @@ -52,7 +52,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = \assert(method_exists($manager, 'getReference')); $newData = $data; $identifiers = array_reverse($uriVariables); - $links = $this->getLinks($class, $operation, $context); + $links = $this->getLinks($context['resource_class'] ?? $class, $operation, $context); $reflectionProperties = $this->getReflectionProperties($data); // TODO: the call to getReference is most likely to fail with complex identifiers diff --git a/src/Doctrine/Odm/State/LinksHandlerTrait.php b/src/Doctrine/Odm/State/LinksHandlerTrait.php index c4e8b651b3..5058b5bd4e 100644 --- a/src/Doctrine/Odm/State/LinksHandlerTrait.php +++ b/src/Doctrine/Odm/State/LinksHandlerTrait.php @@ -37,7 +37,7 @@ private function handleLinks(Builder $aggregationBuilder, array $identifiers, ar return; } - $links = $this->getLinks($resourceClass, $operation, $context); + $links = $this->getLinks($context['resource_class'] ?? $resourceClass, $operation, $context); if (!$links) { return; diff --git a/src/Doctrine/Orm/State/LinksHandlerTrait.php b/src/Doctrine/Orm/State/LinksHandlerTrait.php index 9a088a4e87..4355a747ba 100644 --- a/src/Doctrine/Orm/State/LinksHandlerTrait.php +++ b/src/Doctrine/Orm/State/LinksHandlerTrait.php @@ -40,7 +40,7 @@ private function handleLinks(QueryBuilder $queryBuilder, array $identifiers, Que $doctrineClassMetadata = $manager->getClassMetadata($entityClass); $alias = $queryBuilder->getRootAliases()[0]; - $links = $this->getLinks($entityClass, $operation, $context); + $links = $this->getLinks($context['resource_class'] ?? $entityClass, $operation, $context); if (!$links) { return;