Skip to content

Commit 50bf114

Browse files
committed
fix(serializer): collection denormalization from object linked to doctrine entities
1 parent bd11bd0 commit 50bf114

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Serializer/ItemNormalizer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName
5151
*/
5252
public function denormalize($data, $class, $format = null, array $context = [])
5353
{
54+
if (null === $objectToPopulate = $this->extractObjectToPopulate($class, $context, static::OBJECT_TO_POPULATE)) {
55+
$normalizedData = $this->prepareForDenormalization($data);
56+
$class = $this->getClassDiscriminatorResolvedClass($normalizedData, $class);
57+
}
58+
$resourceClass = $this->resourceClassResolver->getResourceClass($objectToPopulate, $class);
59+
$context['resource_class'] = $resourceClass;
5460
// Avoid issues with proxies if we populated the object
5561
if (isset($data['id']) && !isset($context[self::OBJECT_TO_POPULATE])) {
5662
if (isset($context['api_allow_update']) && true !== $context['api_allow_update']) {

0 commit comments

Comments
 (0)