tour_page_bottom

tour_page_bottom(array &$page_bottom)

Implements hook_page_bottom().

File

core/modules/tour/tour.module, line 76
Main functions of the module.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function tour_page_bottom(array &$page_bottom) {
  if (!\Drupal::currentUser()->hasPermission('access tour')) {
    return;
  }
 
  // Load all of the items and match on route name.
  $route_match = \Drupal::routeMatch();
  $route_name = $route_match->getRouteName();
 
  $results = \Drupal::entityQuery('tour')
    ->condition('routes.*.route_name', $route_name)
    ->execute();
  if (!empty($results) && $tours = Tour::loadMultiple(array_keys($results))) {
    foreach ($tours as $id => $tour) {
      // Match on params.
      if (!$tour->hasMatchingRoute($route_name, $route_match->getRawParameters()->all())) {
        unset($tours[$id]);
      }
    }
    if (!empty($tours)) {
      $page_bottom['tour'] = entity_view_multiple($tours, 'full');
    }
  }
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.