From 1ac4a2050c8076eb96e07e83721ebc9db864db94 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:47:21 +0200 Subject: Adding upstream version 0.3.3. Signed-off-by: Daniel Baumann --- .../Monitoring/IgnoredNotificationPeriods.php | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php (limited to 'library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php') diff --git a/library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php b/library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php new file mode 100644 index 0000000..4b9e94c --- /dev/null +++ b/library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php @@ -0,0 +1,49 @@ + */ + +namespace Icinga\Module\Toplevelview\Monitoring; + +trait IgnoredNotificationPeriods +{ + protected $ignoredNotificationPeriods = []; + + public function ignoreNotificationPeriod($name) + { + $this->ignoredNotificationPeriods[$name] = true; + return $this; + } + + /** + * @param string|array|iterable $list + * + * @return $this + */ + public function ignoreNotificationPeriods($list) + { + if (is_string($list)) { + /** @var string $list */ + $this->ignoredNotificationPeriods[$list] = true; + } else { + foreach ($list as $i) { + $this->ignoredNotificationPeriods[$i] = true; + } + } + + return $this; + } + + public function getIgnoredNotificationPeriods() + { + return array_keys($this->ignoredNotificationPeriods); + } + + public function resetIgnoredNotificationPeriods() + { + $this->ignoredNotificationPeriods = []; + } + + public function hasIgnoredNotifications() + { + return ! empty($this->ignoredNotificationPeriods); + } +} -- cgit v1.2.3