function ToolbarThemeHooks::preprocessToolbarForClaro

Same name and namespace in other branches
  1. main core/modules/toolbar/src/Hook/ToolbarThemeHooks.php \Drupal\toolbar\Hook\ToolbarThemeHooks::preprocessToolbarForClaro()

Implements hook_preprocess_toolbar().

Attributes

#[Hook('preprocess_toolbar')]

File

core/modules/toolbar/src/Hook/ToolbarThemeHooks.php, line 129

Class

ToolbarThemeHooks
Hook implementations for toolbar.

Namespace

Drupal\toolbar\Hook

Code

public function preprocessToolbarForClaro(array &$variables, $hook, $info) : void {
  // When Claro is the admin theme, Claro overrides the active theme's if that
  // active theme is not Claro. Because of these potential overrides, the
  // toolbar cache should be invalidated any time the default or admin theme
  // changes.
  $variables['#cache']['tags'][] = 'config:system.theme';
  // If Claro is the admin theme but not the active theme, still include
  // Claro's toolbar preprocessing.
  if ($this->isClaroAdminAndNotActive()) {
    $variables['attributes']['data-drupal-claro-processed-toolbar'] = TRUE;
  }
}

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