bs_lib-8.x-1.0-alpha3/bs_lib.module
bs_lib.module
<?php /** * @file * Main module file. */ /** * Implements hook_theme(). */ function bs_lib_theme() { return [ 'bs_lib_toggle_button' => [ 'render element' => 'elements', ], ]; } /** * Implements hook_page_attachments(). */ function bs_lib_page_attachments(array &$attachments) { $anchor_scroll = \Drupal::config('bs_lib.settings')->get('anchor_scroll'); if ($anchor_scroll['enable'] && !\Drupal::service('router.admin_context')->isAdminRoute()) { $attachments['#attached']['drupalSettings']['bs_lib']['anchor_scroll'] = $anchor_scroll; $attachments['#attached']['library'][] = 'bs_lib/anchor_scroll'; } } /** * Prepares variables for bs_lib_toogle_button template. */ function template_preprocess_bs_lib_toggle_button(&$variables) { if (!empty($variables['elements']['#options']['attributes'])) { $variables = array_merge($variables, $variables['elements']['#options']); } }