private function SitewideAlertManager::soonestAppearingScheduledAlertDateTime in Sitewide Alert 8
Determines the datetime of the soonest expiring scheduled alert.
Return value
\Drupal\Core\Datetime\DrupalDateTime|null The datetime of the soonest expiring scheduled alert; null if none of the alerts are scheduled to expire.
1 call to SitewideAlertManager::soonestAppearingScheduledAlertDateTime()
- SitewideAlertManager::nextScheduledChange in src/
SitewideAlertManager.php - The time of the next scheduled change of alerts.
File
- src/
SitewideAlertManager.php, line 149
Class
Namespace
Drupal\sitewide_alertCode
private function soonestAppearingScheduledAlertDateTime() {
/** @var DrupalDateTime|null $soonestScheduledEndDate */
$soonestScheduledStartDate = NULL;
foreach ($this
->activeSitewideAlerts() as $sitewideAlert) {
if (!$sitewideAlert
->isScheduled()) {
continue;
}
if (!($startDateTime = $sitewideAlert
->getScheduledStartDateTime())) {
continue;
}
if ($startDateTime
->getPhpDateTime() < $this
->requestDateTime()) {
continue;
}
if ($soonestScheduledStartDate === NULL) {
$soonestScheduledStartDate = $startDateTime;
continue;
}
if ($soonestScheduledStartDate > $startDateTime) {
$soonestScheduledStartDate = $startDateTime;
}
}
return $soonestScheduledStartDate;
}