summaryrefslogtreecommitdiffstats
path: root/library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php')
-rw-r--r--library/Toplevelview/Monitoring/IgnoredNotificationPeriods.php49
1 files changed, 49 insertions, 0 deletions
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 @@
+<?php
+/* Copyright (C) 2019 Icinga Development Team <info@icinga.com> */
+
+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);
+ }
+}