localgov_alert_banner-1.8.5/modules/localgov_alert_banner_full_page/localgov_alert_banner_full_page.module
modules/localgov_alert_banner_full_page/localgov_alert_banner_full_page.module
<?php
/**
* @file
* Hook implementations.
*/
declare(strict_types=1);
use Drupal\Component\Utility\Html;
/**
* Implements hook_theme().
*/
function localgov_alert_banner_full_page_theme(): array {
$theme = [];
$theme['localgov_alert_banner__localgov_full_page'] = [
'base hook' => 'localgov_alert_banner',
];
return $theme;
}
/**
* Implements hook_preprocess_localgov_alert_banner() for hook_preprocess_localgov_alert_banner__full().
*
* - Adds a unique id for the top level wrapper div of the alert banner.
* - Adds relevant Javascript settings and library.
*/
function localgov_alert_banner_full_page_preprocess_localgov_alert_banner__localgov_full_page(&$variables): void {
$alert_banner_id = $variables['attributes']['id'] ?? Html::getUniqueId('localgov-full-page-alert-banner');
$variables['attributes']['id'] = $alert_banner_id;
$variables['#attached']['drupalSettings']['localgov_alert_banner_full_page']['localgov_full_page_alert_banner_id'] = $alert_banner_id;
$variables['#attached']['library'][] = 'localgov_alert_banner_full_page/full_page_alert_banner';
}
