From 590d0d05f327086f403f10ca9e12bf4cb4409824 Mon Sep 17 00:00:00 2001 From: Kai Grassnick Date: Fri, 6 Sep 2024 11:05:36 +0200 Subject: [PATCH] adjust getLinks call to use resource_class from context (if defined) default to old behavior of using entityClass --- 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 20e93ac4399..30ceb357742 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 c4e8b651b38..5058b5bd4ec 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 9a088a4e87a..4355a747ba8 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;