Skip to content

Commit d3bcded

Browse files
authored
fix(metadata): use operation output class for mapping instead of operation class (#7601)
1 parent 9814f27 commit d3bcded

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/State/Provider/ObjectMapperProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct(
3939
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
4040
{
4141
$data = $this->decorated->provide($operation, $uriVariables, $context);
42+
$class = $operation->getOutput()['class'] ?? $operation->getClass();
4243

4344
if (!$this->objectMapper || !$operation->canMap()) {
4445
return $data;
@@ -55,7 +56,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
5556
$data = new MappedObjectPaginator(
5657
iterator_to_array($data),
5758
$this->objectMapper,
58-
$operation->getClass(),
59+
$class,
5960
$data->getTotalItems(),
6061
$data->getCurrentPage(),
6162
$data->getLastPage(),
@@ -64,11 +65,11 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
6465
} elseif (\is_array($data)) {
6566
foreach ($data as &$v) {
6667
if (\is_object($v)) {
67-
$v = $this->objectMapper->map($v, $operation->getClass());
68+
$v = $this->objectMapper->map($v, $class);
6869
}
6970
}
7071
} else {
71-
$data = $this->objectMapper->map($data, $operation->getClass());
72+
$data = $this->objectMapper->map($data, $class);
7273
}
7374

7475
$request?->attributes->set('data', $data);

0 commit comments

Comments
 (0)