You are here

protected function EntityController::getCacheContext in Render cache 7.2

Parameters

object $object:

array $context:

Return value

array

Overrides BaseController::getCacheContext

File

modules/controller/render_cache_entity/src/RenderCache/Controller/EntityController.php, line 28
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 getCacheContext($object, array $context) {

  // Helper variables.
  $entity = $object;
  $entity_type = $context['entity_type'];
  $context = parent::getCacheContext($object, $context);

  // Setup entity context.
  list($entity_id, $entity_revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
  $context = $context + array(
    'entity_id' => $entity_id,
    'entity_revision_id' => $entity_revision_id,
    'bundle' => !empty($bundle) ? $bundle : $entity_type,
  );
  return $context;
}