sticky_toolbar-8.x-1.6/sticky_toolbar.module
sticky_toolbar.module
<?php
/**
* @file
* Sticky Toolbar core functions.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function sticky_toolbar_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.sticky_toolbar':
return '<p>' . t('Toolbar is fixed by default and does not include an option to make it relative in the DOM. This module addresses that need by allowing users to toggle that setting.') . '</p>';
}
}
/**
* Implements hook_page_attachments().
*/
function sticky_toolbar_page_attachments(array &$page) {
$user = \Drupal::currentUser()->id();
$sticky = \Drupal::service('user.data')->get('sticky_toolbar', $user, 'sticky');
// Only attach library if user set sticky toggle to false.
if (!$sticky) {
$page['#attached']['library'][] = 'sticky_toolbar/sticky_toolbar_reset';
}
}
