public function ResourceObjectNormalizationCacher::saveOnTerminate in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/src/EventSubscriber/ResourceObjectNormalizationCacher.php \Drupal\jsonapi\EventSubscriber\ResourceObjectNormalizationCacher::saveOnTerminate()
- 10 core/modules/jsonapi/src/EventSubscriber/ResourceObjectNormalizationCacher.php \Drupal\jsonapi\EventSubscriber\ResourceObjectNormalizationCacher::saveOnTerminate()
Adds a normalization to be cached after the response has been sent.
Parameters
\Drupal\jsonapi\JsonApiResource\ResourceObject $object: The resource object for which to generate a cache item.
array $normalization_parts: The normalization parts to cache.
File
- core/
modules/ jsonapi/ src/ EventSubscriber/ ResourceObjectNormalizationCacher.php, line 93
Class
- ResourceObjectNormalizationCacher
- Caches entity normalizations after the response has been sent.
Namespace
Drupal\jsonapi\EventSubscriberCode
public function saveOnTerminate(ResourceObject $object, array $normalization_parts) {
assert(array_keys($normalization_parts) === [
static::RESOURCE_CACHE_SUBSET_BASE,
static::RESOURCE_CACHE_SUBSET_FIELDS,
]);
$resource_type = $object
->getResourceType();
$key = $resource_type
->getTypeName() . ':' . $object
->getId();
$this->toCache[$key] = [
$object,
$normalization_parts,
];
}