Skip to content

Commit

Permalink
adjust getLinks call to use resource_class from context (if defined) …
Browse files Browse the repository at this point in the history
…default to old behavior of using entityClass
  • Loading branch information
KaiGrassnick committed Sep 6, 2024
1 parent ef0ee64 commit 590d0d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Doctrine/Common/State/PersistProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/State/LinksHandlerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/State/LinksHandlerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 590d0d0

Please sign in to comment.