public static function CacheableNormalization::aggregate in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php \Drupal\jsonapi\Normalizer\Value\CacheableNormalization::aggregate()
- 9 core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php \Drupal\jsonapi\Normalizer\Value\CacheableNormalization::aggregate()
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().
File
- core/
modules/ jsonapi/ 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;
}, []));
}