You are here

function high_contrast_page_attachments in High contrast 8

Implements hook_page_attachments().

Attach the library to the page instead of attaching it to the form, so the high contrast persists even on pages where the HighContrastSwitchForm is not being displayed.

File

./high_contrast.module, line 46
Allows users to switch to a high contrast version of the active theme.

Code

function high_contrast_page_attachments(array &$attachments) {
  $attachments['#cache']['contexts'][] = 'high_contrast';
  $attachments['#cache']['tags'][] = 'config:high_contrast.settings';
  if (HighContrastTrait::highContrastEnabled()) {
    $attachments['#attached']['library'][] = 'high_contrast/high_contrast';
  }
}