function UmamiHooks::preprocessBreadcrumb

Same name and namespace in other branches
  1. 11.x core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php \Drupal\umami\Hook\UmamiHooks::preprocessBreadcrumb()

Implements hook_preprocess_HOOK() for breadcrumb.

Attributes

#[Hook('preprocess_breadcrumb')]

File

core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php, line 153

Class

UmamiHooks
Hook implementations for umami.

Namespace

Drupal\umami\Hook

Code

public function preprocessBreadcrumb(&$variables) : void {
  // We are creating a variable for the Current Page Title, to allow us to
  // print it after the breadcrumbs loop has run.
  $route_match = \Drupal::routeMatch();
  $variables['current_page_title'] = \Drupal::service('title_resolver')->getTitle(\Drupal::request(), $route_match->getRouteObject());
  // Since we are printing the 'Current Page Title', add the URL cache
  // context. If we don't, then we might end up with something like
  // "Home > Articles" on the Recipes page, which should read
  // "Home > Recipes".
  $variables['#cache']['contexts'][] = 'url';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.