You are here

context_active_trail.module in Context Active Trail 8

Same filename and directory in other branches
  1. 8.2 context_active_trail.module

Hook implementations for context_active_trail.

File

context_active_trail.module
View source
<?php

/**
 * @file
 * Hook implementations for context_active_trail.
 */
use Drupal\context\ContextInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Cache tag for things that are dependent on the breadcrumbs configuration.
 *
 * Whenever something might change which breadcrumb builder is responsible for
 * a given breadcrumb, this tag needs to be invalidated.
 */
const CACHE_TAG_BREADCRUMBS = "cache_tag_breadcrumbs";

/**
 * Implements hook_context_update().
 */
function context_active_trail_context_update(ContextInterface $entity) {
  if ($entity->original
    ->hasReaction('active_trail')) {
    Cache::invalidateTags([
      CACHE_TAG_BREADCRUMBS,
    ]);
  }
}

/**
 * Implements hook_context_delete().
 */
function context_active_trail_context_delete(ContextInterface $entity) {
  if ($entity
    ->hasReaction('active_trail')) {
    Cache::invalidateTags([
      CACHE_TAG_BREADCRUMBS,
    ]);
  }
}

/**
 * Implements hook_system_breadcrumb_alter().
 */
function context_active_trail_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context) {
  $breadcrumb
    ->addCacheTags([
    CACHE_TAG_BREADCRUMBS,
  ]);
}

Functions

Namesort descending Description
context_active_trail_context_delete Implements hook_context_delete().
context_active_trail_context_update Implements hook_context_update().
context_active_trail_system_breadcrumb_alter Implements hook_system_breadcrumb_alter().

Constants

Namesort descending Description
CACHE_TAG_BREADCRUMBS Cache tag for things that are dependent on the breadcrumbs configuration.