You are here

function thunder_demo_tour_tips_alter in Thunder 8.5

Same name and namespace in other branches
  1. 8.2 modules/thunder_demo/thunder_demo.module \thunder_demo_tour_tips_alter()
  2. 8.3 modules/thunder_demo/thunder_demo.module \thunder_demo_tour_tips_alter()
  3. 8.4 modules/thunder_demo/thunder_demo.module \thunder_demo_tour_tips_alter()
  4. 6.2.x modules/thunder_demo/thunder_demo.module \thunder_demo_tour_tips_alter()
  5. 6.0.x modules/thunder_demo/thunder_demo.module \thunder_demo_tour_tips_alter()
  6. 6.1.x modules/thunder_demo/thunder_demo.module \thunder_demo_tour_tips_alter()

Implements hook_tour_tips_alter().

Tour depends a lot on used theme. Because of that whitelist is provided, to ensure that tour is loaded only if proper theme is used.

File

modules/thunder_demo/thunder_demo.module, line 16
Provides hooks for demo module.

Code

function thunder_demo_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {

  // Whitelist of tours for frontend and backend theme.
  $tourThemeMapping = [
    'homepage' => [
      'thunder_base',
    ],
    'content-add' => [
      'thunder_admin',
    ],
    'content-list' => [
      'thunder_admin',
    ],
    'content-paragraphs' => [
      'thunder_admin',
    ],
  ];

  // Remove tours that are not whitelisted for provided themes.
  $activeTheme = \Drupal::theme()
    ->getActiveTheme()
    ->getName();
  $tourId = $entity
    ->id();
  if (isset($tourThemeMapping[$tourId]) && !in_array($activeTheme, $tourThemeMapping[$tourId])) {
    $tour_tips = [];
  }
}