$normalizer_values =
$cached_normalization_parts !== FALSE
?
$cached_normalization_parts :
static::
buildEmptyNormalization($object);
$fields = &
$normalizer_values[ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_FIELDS
];
$non_cached_fields =
array_diff_key($object->
getFields(),
$fields);
$non_cached_requested_fields =
array_intersect_key($non_cached_fields,
array_flip($field_names));
foreach ($non_cached_requested_fields as $field_name =>
$field) { $fields[$field_name] =
$this->
serializeField($field,
$context,
$format);
} // Add links if missing.
$base = &
$normalizer_values[ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_BASE
];
$base['links'
] =
$base['links'
] ??
$this->serializer->
normalize($object->
getLinks(),
$format,
$context)->
omitIfEmpty();
if (!
empty($non_cached_requested_fields)) { $this->cacher->
saveOnTerminate($object,
$normalizer_values);
} return $normalizer_values;
} /**
* Builds the empty normalization structure for cache misses.
*
* @param \Drupal\jsonapi\JsonApiResource\ResourceObject $object
* The resource object being normalized.
*
* @return array
* The normalization structure as defined in ::getNormalization().
*
* @see ::getNormalization()
*/