function sitewide_alert_page_top in Sitewide Alert 8
Implements hook_page_top().
File
- ./
sitewide_alert.module, line 29 - Contains sitewide_alert.module.
Code
function sitewide_alert_page_top(array &$page_top) {
// Do not show alert on admin pages if we are not configured to do so.
if (\Drupal::service('router.admin_context')
->isAdminRoute() && !\Drupal::config('sitewide_alert.settings')
->get('show_on_admin')) {
return;
}
$page_top['sitewide_alert'] = [
'#markup' => '<div id="sitewide-alert"></div>',
'#attached' => [
'library' => [
'sitewide_alert/init',
],
'drupalSettings' => [
'sitewideAlert' => [
'refreshInterval' => (\Drupal::config('sitewide_alert.settings')
->get('refresh_interval') ?? 15) * 1000,
'automaticRefresh' => \Drupal::config('sitewide_alert.settings')
->get('automatic_refresh') == 1,
],
],
],
];
}