Sync: allow to remove objects

This commit is contained in:
Thomas Gelf 2015-12-04 10:24:54 +01:00
parent 00cb7bb9d0
commit 2164c1e2b9
2 changed files with 19 additions and 1 deletions

View File

@ -264,7 +264,7 @@ class Sync
}
if (! $found) {
// TODO: temporarily disabled, "mark" them: $object->delete();
$object->markForRemoval();
}
}
@ -298,6 +298,11 @@ class Sync
}
continue;
}
if ($object->shouldBeRemoved()) {
$object->delete($db);
continue;
}
if ($object->hasBeenModified()) {
$object->store($db);
}

View File

@ -51,6 +51,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
private $arguments;
private $shouldBeRemoved = false;
public function propertyIsBoolean($property)
{
return array_key_exists($property, $this->booleans);
@ -191,6 +193,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return parent::set($key, $value);
}
public function markForRemoval($remove = true)
{
$this->shouldBeRemoved = $remove;
return $this;
}
public function shouldBeRemoved()
{
return $this->shouldBeRemoved;
}
public function groups()
{
$this->assertGroupsSupport();