summaryrefslogtreecommitdiffstats
path: root/library/Director/PropertyModifier/PropertyModifierSkipDuplicates.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/PropertyModifier/PropertyModifierSkipDuplicates.php')
-rw-r--r--library/Director/PropertyModifier/PropertyModifierSkipDuplicates.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/library/Director/PropertyModifier/PropertyModifierSkipDuplicates.php b/library/Director/PropertyModifier/PropertyModifierSkipDuplicates.php
new file mode 100644
index 0000000..bf9bd31
--- /dev/null
+++ b/library/Director/PropertyModifier/PropertyModifierSkipDuplicates.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Icinga\Module\Director\PropertyModifier;
+
+use Icinga\Module\Director\Hook\PropertyModifierHook;
+
+class PropertyModifierSkipDuplicates extends PropertyModifierHook
+{
+ private $seen = [];
+
+ public function getName()
+ {
+ return mt('director', 'Skip row if this value appears more than once');
+ }
+
+ public function transform($value)
+ {
+ if (isset($this->seen[$value])) {
+ $this->rejectRow();
+ }
+
+ $this->seen[$value] = true;
+
+ return $value;
+ }
+}