From 013cc1c67dab0d43724ff2a809b186e07bdc90a2 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 29 Feb 2016 19:00:52 +0100 Subject: [PATCH] ExtensibleSet: allow global "set" --- .../Director/IcingaConfig/ExtensibleSet.php | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/library/Director/IcingaConfig/ExtensibleSet.php b/library/Director/IcingaConfig/ExtensibleSet.php index 04106d1c..23e82751 100644 --- a/library/Director/IcingaConfig/ExtensibleSet.php +++ b/library/Director/IcingaConfig/ExtensibleSet.php @@ -57,6 +57,28 @@ class ExtensibleSet return $set; } + public function set($set) + { + if (is_array($set) || is_string($set)) { + $this->reset(); + $this->override($set); + } elseif (is_object($set)) { + $this->reset(); + + foreach (array('override', 'extend', 'blacklist') as $method) { + if (property_exists($set, $method)) { + $this->$method($set->$method); + } + } + } else { + throw new ProgrammingError( + 'ExtensibleSet::set accepts only plain arrays or objects' + ); + } + + return $this; + } + public function hasBeenLoadedFromDb() { return $this->fromDb !== null; @@ -277,7 +299,7 @@ class ExtensibleSet } if ($this->hasBeenResolved()) { - $this->reset(); + $this->resolvedValues = null; } $this->inheritedValues = array(); @@ -449,7 +471,11 @@ class ExtensibleSet protected function reset() { + $this->ownValues = null; + $this->plusValues = array(); + $this->minusValues = array(); $this->resolvedValues = null; + $this->inheritedValues = array(); return $this; }