You are here

function collapsiblock_page_attachments_alter in Collapsiblock 8.2

Same name and namespace in other branches
  1. 4.x collapsiblock.module \collapsiblock_page_attachments_alter()
  2. 3.x collapsiblock.module \collapsiblock_page_attachments_alter()

Implements hook_page_attachments_alter().

Attach our library and global settings.

File

./collapsiblock.module, line 26
Make blocks collapsible.

Code

function collapsiblock_page_attachments_alter(array &$attachments) {
  $attachments['#attached']['library'][] = 'collapsiblock/core';
  $settings = \Drupal::config('collapsiblock.settings');
  $collapsiblock = [
    'active_pages' => $settings
      ->get('active_pages'),
    'slide_type' => $settings
      ->get('slide_type'),
    'slide_speed' => $settings
      ->get('slide_speed'),
  ];
  $attachments['#attached']['drupalSettings']['collapsiblock'] = $collapsiblock;
}