You are here

private function SitewideAlertManager::soonestExpiringVisibleScheduledAlertDateTime in Sitewide Alert 8

Determines the datetime of the soonest expiring visible 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::soonestExpiringVisibleScheduledAlertDateTime()
SitewideAlertManager::nextScheduledChange in src/SitewideAlertManager.php
The time of the next scheduled change of alerts.

File

src/SitewideAlertManager.php, line 117

Class

SitewideAlertManager

Namespace

Drupal\sitewide_alert

Code

private function soonestExpiringVisibleScheduledAlertDateTime() {

  /** @var DrupalDateTime|null $soonestScheduledEndDate */
  $soonestScheduledEndDate = NULL;
  foreach ($this
    ->activeVisibleSitewideAlerts() as $sitewideAlert) {
    if (!$sitewideAlert
      ->isScheduled()) {
      continue;
    }
    if (!($endDateTime = $sitewideAlert
      ->getScheduledEndDateTime())) {
      continue;
    }
    if ($soonestScheduledEndDate === NULL) {
      $soonestScheduledEndDate = $endDateTime;
      continue;
    }
    if ($soonestScheduledEndDate > $endDateTime) {
      $soonestScheduledEndDate = $endDateTime;
    }
  }
  return $soonestScheduledEndDate;
}