class CacheableNormalization implements CacheableDependencyInterface (View source)

internal  JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
 

Use to store normalized data and its cacheability.

Traits

Trait for \Drupal\Core\Cache\CacheableDependencyInterface.

Properties

protected string[] $cacheContexts

Cache contexts.

from  CacheableDependencyTrait
protected string[] $cacheTags

Cache tags.

from  CacheableDependencyTrait
protected int $cacheMaxAge

Cache max-age.

from  CacheableDependencyTrait
protected mixed $normalization

A normalized value.

Methods

$this
setCacheability(CacheableDependencyInterface $cacheability)

Sets cacheability; useful for value object constructors.

getCacheTags()

{@inheritdoc}

__construct(CacheableDependencyInterface $cacheability, array|string|int|float|bool|null $normalization)

CacheableNormalization constructor.

permanent(array|string|int|float|bool|null $normalization)

Creates a CacheableNormalization instance without any special cacheability.

array|string|int|float|bool|null
getNormalization()

Gets the decorated normalization.

omitIfEmpty()

Converts the object to a CacheableOmission if the normalization is empty.

withCacheableDependency(CacheableDependencyInterface $dependency)

Gets a new CacheableNormalization with an additional dependency.

aggregate(array $cacheable_normalizations)

Collects an array of CacheableNormalizations into a single instance.

static bool
hasNoNestedInstances(array|Traversable $array)

Ensures that no nested values are instances of this class.

Details

protected $this setCacheability(CacheableDependencyInterface $cacheability)

Sets cacheability; useful for value object constructors.

Parameters

CacheableDependencyInterface $cacheability

The cacheability to set.

Return Value

$this

getCacheTags()

{@inheritdoc}

getCacheContexts()

{@inheritdoc}

getCacheMaxAge()

{@inheritdoc}

__construct(CacheableDependencyInterface $cacheability, array|string|int|float|bool|null $normalization)

CacheableNormalization constructor.

Parameters

CacheableDependencyInterface $cacheability

The cacheability metadata for the normalized data.

array|string|int|float|bool|null $normalization

The normalized data. This value must not contain any CacheableNormalizations.

static CacheableNormalization permanent(array|string|int|float|bool|null $normalization)

Creates a CacheableNormalization instance without any special cacheability.

Parameters

array|string|int|float|bool|null $normalization

The normalized data. This value must not contain any CacheableNormalizations.

Return Value

CacheableNormalization

The CacheableNormalization.

array|string|int|float|bool|null getNormalization()

Gets the decorated normalization.

Return Value

array|string|int|float|bool|null

The normalization.

CacheableNormalization|CacheableOmission omitIfEmpty()

Converts the object to a CacheableOmission if the normalization is empty.

Return Value

CacheableNormalization|CacheableOmission

A CacheableOmission if the normalization is considered empty, self otherwise.

CacheableNormalization withCacheableDependency(CacheableDependencyInterface $dependency)

Gets a new CacheableNormalization with an additional dependency.

Parameters

CacheableDependencyInterface $dependency

The new cacheable dependency.

Return Value

CacheableNormalization

A new object based on the current value with an additional cacheable dependency.

static CacheableNormalization aggregate(array $cacheable_normalizations)

Collects an array of CacheableNormalizations into a single instance.

Parameters

array $cacheable_normalizations

An array of CacheableNormalizations.

Return Value

CacheableNormalization

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().

static protected bool hasNoNestedInstances(array|Traversable $array)

Ensures that no nested values are instances of this class.

Parameters

array|Traversable $array

The traversable object which may contain instance of this object.

Return Value

bool

Whether the given object or its children have CacheableNormalizations in them.