You are here

function d8cache_entity_view in Drupal 8 Cache Backport 7

Implements hook_entity_view().

File

includes/entity.inc, line 11
Entity functions and hooks for the D8 caching system backport.

Code

function d8cache_entity_view($entity, $entity_type, $view_mode, $langcode) {
  $tags = _d8cache_entity_get_cache_tags($entity_type, $entity);
  $tags[] = $entity_type . '_view';
  if ($entity_type == 'node' && $view_mode != 'full') {

    // @todo Find a better way to add list cache tags.
    $tags = array_merge($tags, _d8cache_entity_get_list_cache_tags($entity_type, $entity));
  }
  $entity->content['#attached']['drupal_add_cache_tags'][][0] = $tags;
}