function display_cache_view_entity

cis7 display_cache.module display_cache_view_entity($entities, $view_mode, $langcode, $entity_type)
cle7 display_cache.module display_cache_view_entity($entities, $view_mode, $langcode, $entity_type)
elmsmedia7 display_cache.module display_cache_view_entity($entities, $view_mode, $langcode, $entity_type)
icor7 display_cache.module display_cache_view_entity($entities, $view_mode, $langcode, $entity_type)
meedjum_blog7 display_cache.module display_cache_view_entity($entities, $view_mode, $langcode, $entity_type)
mooc7 display_cache.module display_cache_view_entity($entities, $view_mode, $langcode, $entity_type)

Alternative entity view callback.

This callback replacing all view callbacks provided by the Entity module. The original callback will be called within this callback. In this way it is possible to return the cached html before a renderable array is build.

See also

entity_view()

display_cache_entity_info_alter()

1 string reference to 'display_cache_view_entity'
display_cache_entity_info_alter in sites/all/modules/ulmus/display_cache/display_cache.module
Implements hook_entity_info_alter().

File

sites/all/modules/ulmus/display_cache/display_cache.module, line 268
Module file for Display Cache.

Code

function display_cache_view_entity($entities, $view_mode, $langcode, $entity_type) {
  $info = entity_get_info($entity_type);
  $return = array();

  foreach ($entities as $entity_id => $entity) {
    $entity_info = entity_get_info($entity_type);
    if (!empty($entity_info['bundle keys']['bundle'])) {
      $bundle_key = $entity_info['bundle keys']['bundle'];
    }
    else {
      $bundle_key = $entity_info['entity keys']['bundle'];
    }
    $bundle = $entity->{$bundle_key};
    $settings = display_cache_get_settings($entity_type, $bundle, $view_mode);
    $render_array = array();

    if ($settings['default']['use'] == DISPLAY_CACHE_ENABLED) {
      // Get rendered HTML from cache.
      $keys = display_cache_get_cache_keys($entity_type, $entity_id, $view_mode, 'entity');
      $cid_parts = array(
        '#cache' => array(
          'keys' => $keys,
          'granularity' => $settings['default']['granularity'],
        ),
      );

      $cid = drupal_render_cid_create($cid_parts);

      $data = cache_get($cid, 'cache_display_cache');
      if (!empty($data->data)) {
        $render_array = $data->data;
      }
    }
    if (empty($render_array)) {
      // Get renderable array.
      if (isset($info['entity view callback'])) {
        $entity = entity_key_array_by_property(array($entity), $info['entity keys']['id']);
        $render_array = $info['entity view callback']($entity, $view_mode, $langcode, $entity_type);
        $render_array = $render_array[$entity_type][$entity_id];
      }
      elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
        $render_array = entity_get_controller($entity_type)->view(array($entity), $view_mode, $langcode);
        $render_array = $render_array[$entity_type][$entity_id];
      }
    }
    $return[$entity_type][$entity_id] = $render_array;
  }

  return $return;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.