function social_tour_page_attachments in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8.2 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8.3 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8.4 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8.5 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8.6 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 8.7 modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 10.3.x modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 10.0.x modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 10.1.x modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
- 10.2.x modules/custom/social_tour/social_tour.module \social_tour_page_attachments()
Implements hook_page_attachments().
This will add the social_tour library to all pages that have a tour enabled so we can start it automatically.
Only for users with access though.
File
- modules/
custom/ social_tour/ social_tour.module, line 101 - The Social Tour module.
Code
function social_tour_page_attachments(array &$page) {
if (!_social_tour_init()) {
return;
}
// Load all of the items and match on route name.
$route_name = \Drupal::routeMatch()
->getRouteName();
$tags = \Drupal::service('social_tour.onboarding')
->getCacheTags($route_name);
// If we have a tour available, and there is at least one tour tip we attach
// our JS library that makes sure the tour pops up immediately.
if ($tags) {
$page['#attached']['library'][] = 'social_tour/social_tour';
$page['#cache']['tags'] = $tags;
}
}