You are here

protected function DataFetcher::addBubbleableMetadata in Typed Data API enhancements 8

Adds the bubbleable metadata of the given data.

Parameters

\Drupal\Core\TypedData\TypedDataInterface $data: The data of which to add the metadata.

\Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata: The bubbleable metadata to which to add the data.

1 call to DataFetcher::addBubbleableMetadata()
DataFetcher::fetchDataBySubPaths in src/DataFetcher.php
Fetches data based upon the given sub-paths.

File

src/DataFetcher.php, line 327

Class

DataFetcher
Implementation of the data fetcher service.

Namespace

Drupal\typed_data

Code

protected function addBubbleableMetadata(TypedDataInterface $data, BubbleableMetadata $bubbleable_metadata) {
  if ($data instanceof PrimitiveInterface) {

    // Primitives do not have any metadata attached.
    return;
  }
  $value = $data
    ->getValue();
  if ($value instanceof CacheableDependencyInterface || $value instanceof AttachmentsInterface) {
    $bubbleable_metadata
      ->addCacheableDependency($value);
  }
}