' . t('About') . '';
$output .= '
' . t("The Tour module provides users with guided tours of the site interface. Each tour consists of several tips that highlight elements of the user interface, guide the user through a workflow, or explain key concepts of the website. For more information, see the online documentation for the Tour module.", [':tour' => 'https://www.drupal.org/documentation/modules/tour']) . '
';
$output .= '' . t('Uses') . '
';
$output .= '';
$output .= '- ' . t('Viewing tours') . '
';
$output .= '- ' . t("If a tour is available on a page, a Tour button will be visible in the toolbar. If you click this button the first tip of the tour will appear. The tour continues after clicking the Next button in the tip. To see a tour users must have the permission Access tour and JavaScript must be enabled in the browser") . '
';
$output .= '- ' . t('Creating tours') . '
';
$output .= '- ' . t("Tours can be written as YAML-documents with a text editor, or using the contributed Tour UI module. For more information, see the online documentation for writing tours.", [':doc_url' => 'https://www.drupal.org/developing/api/tour', ':tour_ui' => 'https://www.drupal.org/project/tour_ui']) . '
';
$output .= '
';
return $output;
}
}
/**
* Implements hook_toolbar().
*/
function tour_toolbar() {
$items = [];
$items['tour'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
if (!\Drupal::currentUser()->hasPermission('access tour')) {
return $items;
}
$items['tour'] += [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'html_tag',
'#tag' => 'button',
'#value' => t('Tour'),
'#attributes' => [
'class' => ['toolbar-icon', 'toolbar-icon-help'],
'aria-pressed' => 'false',
'type' => 'button',
],
],
'#wrapper_attributes' => [
'class' => ['tour-toolbar-tab', 'hidden'],
'id' => 'toolbar-tab-tour',
],
'#attached' => [
'library' => [
'tour/tour',
],
],
];
return $items;
}
/**
* Implements hook_page_bottom().
*/
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');
}
}
}
/**
* Implements hook_ENTITY_TYPE_insert() for tour entities.
*/
function tour_tour_insert($entity) {
\Drupal::service('plugin.manager.tour.tip')->clearCachedDefinitions();
}
/**
* Implements hook_ENTITY_TYPE_update() for tour entities.
*/
function tour_tour_update($entity) {
\Drupal::service('plugin.manager.tour.tip')->clearCachedDefinitions();
}