From 321f9d9503106157b61576b1d6f4d87cd40092d7 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 29 Jun 2015 12:50:59 +0200 Subject: [PATCH] IcingaObjectImports: Fix bug with on delete --- library/Director/Objects/IcingaObjectImports.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/library/Director/Objects/IcingaObjectImports.php b/library/Director/Objects/IcingaObjectImports.php index 7b7e5627..c7756d9d 100644 --- a/library/Director/Objects/IcingaObjectImports.php +++ b/library/Director/Objects/IcingaObjectImports.php @@ -93,6 +93,10 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer return $this; } + if (count($new) === 0) { + return $this->clear(); + } + $this->imports = array(); return $this->add($import); } @@ -107,6 +111,16 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer return array_key_exists($import, $this->imports); } + public function clear() + { + $this->imports = array(); + + $this->modified = true; + $this->refreshIndex(); + + return $this; + } + public function remove($import) { if (array_key_exists($import, $this->imports)) { @@ -115,6 +129,8 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer $this->modified = true; $this->refreshIndex(); + + return $this; } protected function refreshIndex()