You are here

function display_cache_get_cached_display in Display Cache 7

Check for cached display.

Parameters

string $entity_type: The entity type.

string $bundle: The bundle.

int $entity_id: The entity id.

string $view_mode: The view mode.

string $element: Element which is cached like 'entity', 'field' or 'render_array'.

Return value

array A render array containing only a #markup index.

1 call to display_cache_get_cached_display()
display_cache_view_entity in ./display_cache.module
Alternative entity view callback.

File

./display_cache.module, line 454
Module file for Display Cache.

Code

function display_cache_get_cached_display($entity_type, $bundle = NULL, $entity_id = NULL, $view_mode = NULL, $element = 'entity') {

  // Initiate result.
  $result = array();

  // Get settings.
  $settings = display_cache_get_settings($entity_type, $bundle, $view_mode);
  if ($settings['default']['use'] == DISPLAY_CACHE_ENABLED) {

    // Get rendered HTML from cache.
    $keys = display_cache_get_cache_keys($entity_type, $entity_id, $view_mode, $element);
    $cid_parts = array(
      '#cache' => array(
        'keys' => $keys,
        'granularity' => $settings['default']['granularity'],
      ),
    );
    $cid = drupal_render_cid_create($cid_parts);
    $data = cache_get($cid, DISPLAY_CACHE_CACHE_BIN);
    if (!empty($data->data)) {
      $result = $data->data;
    }
  }
  return $result;
}