public static function CacheableNormalization::aggregate in JSON:API 8.2
Collects an array of CacheableNormalizations into a single instance.
Parameters
\Drupal\jsonapi\Normalizer\Value\CacheableNormalization[] $cacheable_normalizations: An array of CacheableNormalizations.
Return value
static A new CacheableNormalization. Each input value's cacheability will be merged into the return value's cacheability. The return value's normalization will be an array of the input's normalizations. This method does *not* behave like array_merge() or NestedArray::mergeDeep().
5 calls to CacheableNormalization::aggregate()
- DataNormalizer::normalize in src/
Normalizer/ DataNormalizer.php - Normalizes an object into a set of arrays/scalars.
- EntityReferenceFieldNormalizer::normalize in src/
Normalizer/ EntityReferenceFieldNormalizer.php - Normalizes an object into a set of arrays/scalars.
- FieldNormalizer::normalize in src/
Normalizer/ FieldNormalizer.php - Normalizes an object into a set of arrays/scalars.
- JsonApiDocumentTopLevelNormalizer::normalizeOmissionsLinks in src/
Normalizer/ JsonApiDocumentTopLevelNormalizer.php - Normalizes omitted data into a set of omission links.
- LinkCollectionNormalizer::normalize in src/
Normalizer/ LinkCollectionNormalizer.php - Normalizes an object into a set of arrays/scalars.
File
- src/
Normalizer/ Value/ CacheableNormalization.php, line 106
Class
- CacheableNormalization
- Use to store normalized data and its cacheability.
Namespace
Drupal\jsonapi\Normalizer\ValueCode
public static function aggregate(array $cacheable_normalizations) {
assert(Inspector::assertAllObjects($cacheable_normalizations, CacheableNormalization::class));
return new static(array_reduce($cacheable_normalizations, function (CacheableMetadata $merged, CacheableNormalization $item) {
return $merged
->addCacheableDependency($item);
}, new CacheableMetadata()), array_reduce(array_keys($cacheable_normalizations), function ($merged, $key) use ($cacheable_normalizations) {
if (!$cacheable_normalizations[$key] instanceof CacheableOmission) {
$merged[$key] = $cacheable_normalizations[$key]
->getNormalization();
}
return $merged;
}, []));
}