You are here

protected function EntityQueryAlter::hasCacheableMetadata in Entity API 8

Check if the cacheable metadata is not empty.

An empty cacheable metadata object has no context, tags, and is permanent.

Parameters

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

Return value

bool TRUE if there is cacheability metadata, otherwise FALSE.

1 call to EntityQueryAlter::hasCacheableMetadata()
EntityQueryAlter::applyCacheability in src/QueryAccess/EntityQueryAlter.php
Applies the cacheablity metadata to the current request.

File

src/QueryAccess/EntityQueryAlter.php, line 193

Class

EntityQueryAlter
Defines a class for altering entity queries.

Namespace

Drupal\entity\QueryAccess

Code

protected function hasCacheableMetadata(CacheableMetadata $cacheable_metadata) {
  return $cacheable_metadata
    ->getCacheMaxAge() !== Cache::PERMANENT || count($cacheable_metadata
    ->getCacheContexts()) > 0 || count($cacheable_metadata
    ->getCacheTags()) > 0;
}