mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-24 14:24:42 +02:00
CustomVariables: handle deleted vars
This commit is contained in:
parent
4780e11241
commit
3a96f9ebe4
@ -89,7 +89,12 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
|
||||
|
||||
protected function refreshIndex()
|
||||
{
|
||||
$this->idx = array_keys($this->vars);
|
||||
$this->idx = array();
|
||||
foreach ($this->vars as $name => $var) {
|
||||
if (! $var->hasBeenDeleted()) {
|
||||
$this->idx[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadForStoredObject(IcingaObject $object)
|
||||
@ -223,10 +228,11 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
|
||||
public function __unset($key)
|
||||
{
|
||||
if (! array_key_exists($key, $this->vars)) {
|
||||
throw new Exception('Trying to unset invalid key');
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->vars[$key]);
|
||||
$this->vars[$key]->delete();
|
||||
$this->modified = true;
|
||||
|
||||
$this->refreshIndex();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user