$values =
[];
$context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY
] =
new CacheableMetadata();
if (!
empty($field_item->
getProperties(TRUE
))) { // We normalize each individual value, so each can do their own casting,
// if needed.
$field_properties = TypedDataInternalPropertiesHelper::
getNonInternalProperties($field_item);
foreach ($field_properties as $property_name =>
$property) { $values[$property_name] =
$this->serializer->
normalize($property,
$format,
$context);
} // Flatten if there is only a single property to normalize.
$flatten =
count($field_properties) === 1 &&
$field_item::
mainPropertyName() !== NULL;
$values =
static::
rasterizeValueRecursive($flatten ?
reset($values) :
$values);
} else { $values =
$field_item->
getValue();
} $normalization =
new CacheableNormalization( $context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY
],
$values );
unset($context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY
]);
return $normalization;
}