site_alert.module in Site Alert 8
Same filename and directory in other branches
Allows admins to display a site-wide alert to all users.
When enabled this module allows alerts (of different severity levels) to be displayed (or scheduled to be displayed). Users can dismiss these alerts.
File
site_alert.moduleView source
<?php
/**
* @file
* Allows admins to display a site-wide alert to all users.
*
* When enabled this module allows alerts (of different severity levels) to be
* displayed (or scheduled to be displayed). Users can dismiss these alerts.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\site_alert\Plugin\Block\SiteAlertBlock;
/**
* The default timeout for refreshing site alerts.
*
* @deprecated in site_alert:8.x-1.1 and is removed from site_alert:9.x-0.0. Use
* \Drupal\site_alert\Plugin\Block\SiteAlertBlock::TIMEOUT_DEFAULT instead.
* @see https://www.drupal.org/project/site_alert/issues/3118244
*/
require_once __DIR__ . '/src/Plugin/Block/SiteAlertBlock.php';
define('SITE_ALERT_TIMEOUT_DEFAULT', SiteAlertBlock::TIMEOUT_DEFAULT);
/**
* Implements hook_help().
*/
function site_alert_help($route_name, RouteMatchInterface $route_match) {
$output = '';
switch ($route_name) {
case 'help.page.site_alert':
$output .= '<p>';
$output .= 'Site alert allows a privileged user to display an alert';
$output .= ' across the top of every page to every user. Site alerts can';
$output .= ' be scheduled to turn on a specific date and time as well as';
$output .= ' expire on a specific date and time. ';
$output .= '</p>';
$output .= '<p>';
$output .= 'Users must select a "severity" when managing site alerts.';
$output .= ' This indicates to the theme how the alert should look. For';
$output .= ' example, a high severity message may be styled in red or';
$output .= ' may have a specific animation to ensure users see it.';
$output .= '</p>';
break;
}
return $output;
}
/**
* Implements hook_theme().
*/
function site_alert_theme($existing, $type, $theme, $path) {
return [
'site_alert' => [
'variables' => [
'alert' => [],
],
],
];
}
Functions
Name | Description |
---|---|
site_alert_help | Implements hook_help(). |
site_alert_theme | Implements hook_theme(). |
Constants
Name | Description |
---|---|
SITE_ALERT_TIMEOUT_DEFAULT |