+ /**
+ * Normalizes field values for an item.
+ *
+ * @param \Drupal\Core\Field\FieldItemInterface $field_item
+ * The field item instance.
+ * @param string|null $format
+ * The normalization format.
+ * @param array $context
+ * The context passed into the normalizer.
+ *
+ * @return array
+ * An array of field item values, keyed by property name.
+ */
+ protected function normalizedFieldValues(FieldItemInterface $field_item, $format, array $context) {
+ $normalized = [];
+ // We normalize each individual property, so each can do their own casting,
+ // if needed.
+ /** @var \Drupal\Core\TypedData\TypedDataInterface $property */
+ foreach ($field_item as $property_name => $property) {
+ $normalized[$property_name] = $this->serializer->normalize($property, $format, $context);
+ }
+
+ if (isset($context['langcode'])) {
+ $normalized['lang'] = $context['langcode'];
+ }
+
+ return $normalized;
+ }
+