$field_normalizations =
array_intersect_key($fields,
array_flip($field_names));
$relationship_field_names =
array_keys($resource_type->
getRelatableResourceTypes());
$attributes =
array_diff_key($field_normalizations,
array_flip($relationship_field_names));
$relationships =
array_intersect_key($field_normalizations,
array_flip($relationship_field_names));
$entity_normalization =
array_filter( $normalization_parts[ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_BASE
] +
[ 'attributes' => CacheableNormalization::
aggregate($attributes)->
omitIfEmpty(),
'relationships' => CacheableNormalization::
aggregate($relationships)->
omitIfEmpty(),
] );
return CacheableNormalization::
aggregate($entity_normalization)->
withCacheableDependency($object);
} /**
* Normalizes an entity using the given fieldset.
*
* @param string[] $field_names
* The field names to normalize (the sparse fieldset, if any).
* @param \Drupal\jsonapi\JsonApiResource\ResourceObject $object
* The resource object to partially normalize.
* @param string $format
* The format in which the normalization will be encoded.
* @param array $context
* Context options for the normalizer.
*
* @return array
* An array with two key-value pairs:
* - 'base': array, the base normalization of the entity, that does not
* depend on which sparse fieldset was requested.
* - 'fields': CacheableNormalization for all requested fields.
*
* @see ::normalize()
*/