You are here

protected function EntityController::getCacheHash in Render cache 7.2

Parameters

object $object:

array $context:

Return value

array

Overrides BaseController::getCacheHash

File

modules/controller/render_cache_entity/src/RenderCache/Controller/EntityController.php, line 59
Contains \Drupal\render_cache_entity\RenderCache\Controller\EntityController

Class

EntityController
EntityController - Provides render caching for entity objects.

Namespace

Drupal\render_cache_entity\RenderCache\Controller

Code

protected function getCacheHash($object, array $context) {

  // Helper variables.
  $entity = $object;

  // Calculate hash to expire cached items automatically.
  $hash = parent::getCacheHash($object, $context);
  $hash['entity_id'] = $context['entity_id'];
  $hash['entity_revision_id'] = $context['entity_revision_id'];
  $hash['bundle'] = $context['bundle'];
  $hash['langcode'] = $context['langcode'];

  // @todo Move to cache tags.
  $hash['modified'] = entity_modified_last($context['entity_type'], $entity);
  return $hash;
}