annoying_popup-1.0.0/annoying_popup.module

annoying_popup.module
<?php

/**
 * @file
 * This module lets you annoy your visitors with popups.
 */

/**
 * Implements hook_page_attachments().
 */
function annoying_popup_page_attachments(array &$attachments) {
  if (\Drupal::service('annoying_popup.repository')->hasPopupsForCurrentPath()) {
    $attachments['#attached']['library'][] = 'annoying_popup/annoying_popup';
    $attachments['#attached']['drupalSettings']['annoyingPopup'] = \Drupal::service('annoying_popup.repository')
      ->getPopupsForCurrentPathJavaScriptSettings();
    /*
     * If eu_cookie_compliance is available,
     * make the JS aware of cookie acceptance.
     */
    if (\Drupal::service('module_handler')
      ->moduleExists('eu_cookie_compliance')) {

      // Get the current user.
      $user = \Drupal::currentUser();

      // Check for permission.
      if ($user->hasPermission('display eu cookie compliance popup')) {
        $attachments['#attached']['drupalSettings']['annoyingPopupCookieAware'] = \Drupal::service('module_handler')
          ->moduleExists('eu_cookie_compliance');
        $attachments['#cache']['tags'] = \Drupal::service('annoying_popup.repository')->getCacheTags();
      }
    }
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc