public function SitewideAlertManager::activeVisibleSitewideAlerts in Sitewide Alert 8
Returns all active and currently visible sitewide alerts.
Return value
\Drupal\sitewide_alert\Entity\SitewideAlertInterface[] Array of active sitewide alerts indexed by their ids.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to SitewideAlertManager::activeVisibleSitewideAlerts()
- SitewideAlertManager::soonestExpiringVisibleScheduledAlertDateTime in src/
SitewideAlertManager.php - Determines the datetime of the soonest expiring visible scheduled alert.
File
- src/
SitewideAlertManager.php, line 71
Class
Namespace
Drupal\sitewide_alertCode
public function activeVisibleSitewideAlerts() {
/** @var \Drupal\sitewide_alert\Entity\SitewideAlertInterface[] $activeVisibleSitewideAlerts */
$activeVisibleSitewideAlerts = $this
->activeSitewideAlerts();
// Remove any sitewide alerts that are scheduled and it is not time to show them.
foreach ($activeVisibleSitewideAlerts as $id => $sitewideAlert) {
if ($sitewideAlert
->isScheduled() && !$sitewideAlert
->isScheduledToShowAt($this
->requestDateTime())) {
unset($activeVisibleSitewideAlerts[$id]);
}
}
return $activeVisibleSitewideAlerts;
}