Commit 1a3a315d authored by Sascha Eggenberger's avatar Sascha Eggenberger
Browse files

New Drupal navigation support

parent 4e66cd7c
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -42,9 +42,17 @@ function gin_toolbar_preprocess_html(&$variables) {
    return;
  }

  $module_handler = \Drupal::service('module_handler');

  // Check for new Drupal navigation
  if ($module_handler->moduleExists('navigation')) {
    // Set toolbar class.
    $variables['attributes']['class'][] = 'gin--navigation';
  } else {
    // Set toolbar class.
    $variables['attributes']['class'][] = 'gin--' . $toolbar . '-toolbar';
  }
}

/**
 * Implements hook_preprocess_HOOK() for page_attachments.
@@ -58,7 +66,15 @@ function gin_toolbar_page_attachments_alter(&$page) {
  // Get theme settings.
  /** @var \Drupal\gin\GinSettings $settings */
  $settings = \Drupal::classResolver(GinSettings::class);
  $module_handler = \Drupal::service('module_handler');

  // Check for new Drupal navigation
  if ($module_handler->moduleExists('navigation')) {
    // Set toolbar class.
    $toolbar = 'new';
  } else {
    $toolbar = $settings->get('classic_toolbar');
  }

  // Attach the base library.
  $page['#attached']['library'][] = 'gin/gin_base';
@@ -74,6 +90,10 @@ function gin_toolbar_page_attachments_alter(&$page) {
    // Attach the horizontal toolbar styles.
    $page['#attached']['library'][] = 'gin/gin_horizontal_toolbar';
  }
  elseif ($toolbar === 'new') {
    // Attach the new drupal navigation styles.
    $page['#attached']['library'][] = 'gin/navigation';
  }
  else {
    // Attach toolbar styles.
    $page['#attached']['library'][] = 'gin/gin_toolbar';