mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-26 07:14:59 +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()
|
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)
|
public static function loadForStoredObject(IcingaObject $object)
|
||||||
@ -223,10 +228,11 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
|
|||||||
public function __unset($key)
|
public function __unset($key)
|
||||||
{
|
{
|
||||||
if (! array_key_exists($key, $this->vars)) {
|
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();
|
$this->refreshIndex();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user