function varbase_tour_page_attachments in Varbase Core 8.7
Same name and namespace in other branches
- 8.8 modules/varbase_tour/varbase_tour.module \varbase_tour_page_attachments()
- 8.4 modules/varbase_tour/varbase_tour.module \varbase_tour_page_attachments()
- 8.5 modules/varbase_tour/varbase_tour.module \varbase_tour_page_attachments()
- 8.6 modules/varbase_tour/varbase_tour.module \varbase_tour_page_attachments()
- 9.0.x modules/varbase_tour/varbase_tour.module \varbase_tour_page_attachments()
Implements hook_page_attachments().
File
- modules/
varbase_tour/ varbase_tour.module, line 11 - Contains varbase_tour.module.
Code
function varbase_tour_page_attachments(array &$page) {
// Given that the current user is a logged in user.
if (\Drupal::currentUser()
->isAuthenticated()) {
// When the url is NOT an admin route or in the admin theme.
if (!\Drupal::service('router.admin_context')
->isAdminRoute()) {
// Then attach the seven tour styling library.
// And attach the varbase tour default theme library.
$page['#attached']['library'][] = 'seven/tour-styling';
// $page['#attached']['library'][] = 'varbase_tour/admin-theme';
$page['#attached']['library'][] = 'varbase_tour/default-theme';
}
// When the current page is the front page.
if (\Drupal::service('path.matcher')
->isFrontPage()) {
$query_welcome = \Drupal::request()->query
->get('welcome');
if (isset($query_welcome)) {
$varbase_tour_config = \Drupal::service('config.factory')
->getEditable('varbase_core.general_settings');
$welcome_status = $varbase_tour_config
->get('welcome_status');
// When we do have "/?tour=1&welcome=done" is in the URL address.
// for the front page.
if ($query_welcome == 'done' && isset($welcome_status) && $welcome_status == 1) {
// Then update the "welcome status" checkbox config to unchecked.
$varbase_tour_config
->set('welcome_status', 0);
$varbase_tour_config
->save();
}
}
}
}
}