class ResourceObjectNormalizationCacher implements EventSubscriberInterface (View source)

internal  
 

Caches entity normalizations after the response has been sent.

Refactor once https://www.drupal.org/node/2551419 lands.

Constants

RESOURCE_CACHE_SUBSET_BASE

Key for the base subset.

The base subset contains the parts of the normalization that are always present. The presence or absence of these are not affected by the requested sparse field sets. This typically includes the resource type name, and the resource ID.

RESOURCE_CACHE_SUBSET_FIELDS

Key for the fields subset.

The fields subset contains the parts of the normalization that can appear in a normalization based on the selected field set. This subset is incrementally built across different requests for the same resource object. A given field is normalized and put into the cache whenever there is a cache miss for that field.

Properties

protected RenderCacheInterface $renderCache

The render cache.

protected array $toCache

The things to cache after the response has been sent.

Methods

setRenderCache(RenderCacheInterface $render_cache)

Sets the render cache service.

array|false
get(ResourceObject $object)

Reads an entity normalization from cache.

saveOnTerminate(ResourceObject $object, array $normalization_parts)

Adds a normalization to be cached after the response has been sent.

onTerminate(TerminateEvent $event)

Writes normalizations of entities to cache, if any were created.

set(ResourceObject $object, array $normalization_parts)

Writes a normalization to cache.

static array
generateLookupRenderArray(ResourceObject $object)

Generates a lookup render array for a normalization.

static 
getSubscribedEvents()

{@inheritdoc}

mergeCacheableDependencies(array $dependencies)

Determines the joint cacheability of all provided dependencies.

Details

setRenderCache(RenderCacheInterface $render_cache)

Sets the render cache service.

Parameters

RenderCacheInterface $render_cache

The render cache.

array|false get(ResourceObject $object)

Reads an entity normalization from cache.

The returned normalization may only be a partial normalization because it was previously normalized with a sparse fieldset.

Parameters

ResourceObject $object

The resource object for which to generate a cache item.

Return Value

array|false

The cached normalization parts, or FALSE if not yet cached.

See also

DynamicPageCacheSubscriber::renderArrayToResponse

saveOnTerminate(ResourceObject $object, array $normalization_parts)

Adds a normalization to be cached after the response has been sent.

Parameters

ResourceObject $object

The resource object for which to generate a cache item.

array $normalization_parts

The normalization parts to cache.

onTerminate(TerminateEvent $event)

Writes normalizations of entities to cache, if any were created.

Parameters

TerminateEvent $event

The Event to process.

protected set(ResourceObject $object, array $normalization_parts)

Writes a normalization to cache.

Refactor/remove once https://www.drupal.org/node/2551419 lands.

Parameters

ResourceObject $object

The resource object for which to generate a cache item.

array $normalization_parts

The normalization parts to cache.

See also

DynamicPageCacheSubscriber::responseToRenderArray

static protected array generateLookupRenderArray(ResourceObject $object)

Generates a lookup render array for a normalization.

Parameters

ResourceObject $object

The resource object for which to generate a cache item.

Return Value

array

A render array for use with the RenderCache service.

See also

DynamicPageCacheSubscriber::$dynamicPageCacheRedirectRenderArray

static getSubscribedEvents()

{@inheritdoc}

static protected CacheableMetadata mergeCacheableDependencies(array $dependencies)

Determines the joint cacheability of all provided dependencies.

Parameters

array $dependencies

The dependencies.

Return Value

CacheableMetadata

The cacheability of all dependencies.

See also

RefinableCacheableDependencyInterface::addCacheableDependency