You are here

function d8cache_block_view_alter in Drupal 8 Cache Backport 7

Implements hook_block_view_alter().

File

includes/block.inc, line 20
Block functions and hooks for the D8 caching system backport.

Code

function d8cache_block_view_alter(&$data, $block) {
  $tags = _d8cache_block_get_cache_tags($block);
  $tags[] = 'block_view';
  drupal_add_cache_tags($tags);
  $cid = _block_get_cache_id($block);

  // If this cid is empty, reset the state of the current attachments
  // collector group.
  if (empty($cid)) {
    $cache = d8cache_cache_get_object('cache_block');
    if (is_object($cache) && $cache instanceof D8CacheAttachmentsCollector) {

      /** @var D8CacheAttachmentsCollector $cache */
      $cache
        ->resetCurrentAttachmentsCollector();
    }
  }
}