You are here

function display_cache_clear_comment_host_entity_cache in Display Cache 7

Clears the given comments' host entity if needed.

Parameters

Object $comment: The comment.

3 calls to display_cache_clear_comment_host_entity_cache()
display_cache_comment_delete in ./display_cache.module
Implements hook_comment_delete().
display_cache_comment_publish in ./display_cache.module
Implements hook_comment_publish().
display_cache_comment_update in ./display_cache.module
Implements hook_comment_update().

File

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

Code

function display_cache_clear_comment_host_entity_cache($comment) {
  if ($comment->nid) {
    $node = node_load($comment->nid);
    $should_clear_host_entity_cache_globally = variable_get('display_cache_comment_publication_clears_host_entity_cache_' . $node->type, FALSE);
    $view_modes_to_clear = display_cache_get_comment_publication_clears_host_entity_cache_settings('node', $node->type);
    if ($should_clear_host_entity_cache_globally) {
      display_cache_flush_cache('node', $node);
    }
    elseif (!empty($view_modes_to_clear) && array_sum($view_modes_to_clear) > 0) {
      foreach ($view_modes_to_clear as $view_mode => $clear) {
        if ($clear) {
          display_cache_flush_cache('node', $node, $view_mode);
        }
      }
    }
  }
}