function tour_page_bottom

Same name in other branches
  1. 9 core/modules/tour/tour.module \tour_page_bottom()
  2. 10 core/modules/tour/tour.module \tour_page_bottom()
  3. 11.x core/modules/tour/tour.module \tour_page_bottom()

Implements hook_page_bottom().

File

core/modules/tour/tour.module, line 77

Code

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'] = \Drupal::entityTypeManager()->getViewBuilder('tour')
                ->viewMultiple($tours, 'full');
        }
    }
}

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