Skip to content

Commit ca8f6f7

Browse files
committed
Apply review comments
- Prevent BC change on AbstractItemNormalizer::transformOutput - Remove useless documentation
1 parent e2182be commit ca8f6f7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Serializer/AbstractItemNormalizer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function normalize($object, $format = null, array $context = [])
119119
throw new LogicException('Cannot normalize the output because the injected serializer is not a normalizer');
120120
}
121121

122-
if ($object !== $transformed = $this->transformOutput($object, $outputClass, $context)) {
122+
if ($object !== $transformed = $this->transformOutput($object, $context, $outputClass)) {
123123
$context['api_normalize'] = true;
124124
$context['api_resource'] = $object;
125125
unset($context['output'], $context['resource_class']);
@@ -645,8 +645,12 @@ protected function getDataTransformer($data, string $to, array $context = []): ?
645645
* For a given resource, it returns an output representation if any
646646
* If not, the resource is returned.
647647
*/
648-
protected function transformOutput($object, string $outputClass, array $context = [])
648+
protected function transformOutput($object, array $context = [], string $outputClass = null)
649649
{
650+
if (null === $outputClass) {
651+
$outputClass = $this->getOutputClass($this->getObjectClass($object), $context);
652+
}
653+
650654
if (null !== $outputClass && null !== $dataTransformer = $this->getDataTransformer($object, $outputClass, $context)) {
651655
return $dataTransformer->transform($object, $outputClass, $context);
652656
}

tests/Fixtures/TestBundle/DataTransformer/OutputDtoSameClassTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoOutputSameClass;
2222

2323
/**
24-
* OutputDtoUnmodifiedDataTransformer.
25-
*
2624
* @author Daniel West <[email protected]>
2725
*/
2826
final class OutputDtoSameClassTransformer implements DataTransformerInterface

0 commit comments

Comments
 (0)