You are here

protected function NormalizerBase::addCacheableDependency in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::addCacheableDependency()
  2. 10 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::addCacheableDependency()

Adds cacheability if applicable.

Parameters

array $context: Context options for the normalizer.

$data: The data that might have cacheability information.

4 calls to NormalizerBase::addCacheableDependency()
ContentEntityNormalizer::getEntityUri in core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
Constructs the entity URI.
EntityReferenceFieldItemNormalizer::normalize in core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php
Normalizes an object into a set of arrays/scalars.
FileEntityNormalizer::normalize in core/modules/hal/src/Normalizer/FileEntityNormalizer.php
TypedDataNormalizer::normalize in core/modules/serialization/src/Normalizer/TypedDataNormalizer.php
Normalizes an object into a set of arrays/scalars.

File

core/modules/serialization/src/Normalizer/NormalizerBase.php, line 95

Class

NormalizerBase
Base class for Normalizers.

Namespace

Drupal\serialization\Normalizer

Code

protected function addCacheableDependency(array $context, $data) {
  if ($data instanceof CacheableDependencyInterface && isset($context[static::SERIALIZATION_CONTEXT_CACHEABILITY])) {
    $context[static::SERIALIZATION_CONTEXT_CACHEABILITY]
      ->addCacheableDependency($data);
  }
}