You are here

protected function ViewsQueryAlter::applyCacheability in Entity API 8

Applies the cacheablity metadata to the current request.

Parameters

\Drupal\Core\Cache\CacheableMetadata $cacheable_metadata: The cacheability metadata.

1 call to ViewsQueryAlter::applyCacheability()
ViewsQueryAlter::alter in src/QueryAccess/ViewsQueryAlter.php
Alters the given views query.

File

src/QueryAccess/ViewsQueryAlter.php, line 242

Class

ViewsQueryAlter
Defines a class for altering views queries.

Namespace

Drupal\entity\QueryAccess

Code

protected function applyCacheability(CacheableMetadata $cacheable_metadata) {
  $request = $this->requestStack
    ->getCurrentRequest();
  if ($request
    ->isMethodCacheable() && $this->renderer
    ->hasRenderContext()) {
    $build = [];
    $cacheable_metadata
      ->applyTo($build);
    $this->renderer
      ->render($build);
  }
}