You are here

function modal_page_preprocess_html in Modal 8

Same name and namespace in other branches
  1. 8.3 modal_page.module \modal_page_preprocess_html()
  2. 8.2 modal_page.module \modal_page_preprocess_html()
  3. 5.0.x modal_page.module \modal_page_preprocess_html()
  4. 4.0.x modal_page.module \modal_page_preprocess_html()
  5. 4.1.x modal_page.module \modal_page_preprocess_html()

Implements hook_preprocess_html().

File

./modal_page.module, line 45
Main file for the Modal Page.

Code

function modal_page_preprocess_html(&$variables) {
  $config = \Drupal::config('modal_page.settings');
  $modals = $config
    ->get('modals');
  $modals_by_parameter = $config
    ->get('modals_by_parameter');
  if (empty($modals) && empty($modals_by_parameter)) {
    return FALSE;
  }
  $modal_to_show = \Drupal::service('modal_page.modals')
    ->checkModalToShow();
  if ($modal_to_show) {
    $do_not_show_again = $modal_to_show['do_not_show_again'];
    $title = $modal_to_show['title'];
    $text = $modal_to_show['text'];
    $button = $modal_to_show['button'];
    $id = $modal_to_show['id'];
    $variables['page_top']['slidedown_templates'] = [
      '#theme' => 'modal_page_modal',
      '#do_not_show_again' => $do_not_show_again,
      '#title' => $title,
      '#text' => $text,
      '#button' => $button,
      '#id' => $id,
    ];
    if (isset($modal_to_show['do_not_show_again']) && !empty($modal_to_show['do_not_show_again'])) {
      $variables['page_top']['slidedown_templates']['#do_not_show_again'] = $modal_to_show['do_not_show_again'];
    }
  }
}