getParent() == NULL) { throw new InvalidArgumentException('The field passed in via $context[\'target_instance\'] must have a parent set.'); } /** @var \Drupal\Core\Field\FieldItemListInterface $items */ $items = $context['target_instance']; $item_class = $items->getItemDefinition()->getClass(); if (!is_array($data)) { throw new UnexpectedValueException(sprintf('Field values for "%s" must use an array structure', $items->getName())); } foreach ($data as $item_data) { // Create a new item and pass it as the target for the unserialization of // $item_data. All items in field should have removed before this method // was called. // @see \Drupal\serialization\Normalizer\ContentEntityNormalizer::denormalize(). $context['target_instance'] = $items->appendItem(); $this->serializer->denormalize($item_data, $item_class, $format, $context); } return $items; } }