mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 09:14:09 +02:00
BranchActivity: require connection when creating...
...new objects
This commit is contained in:
parent
767329443b
commit
95730fb0aa
@ -133,14 +133,21 @@ class BranchActivity
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function createDbObject()
|
||||
/**
|
||||
* Hint: $connection is required, because setting groups triggered loading them.
|
||||
* Should be investigated, as in theory $hostWithoutConnection->groups = 'group'
|
||||
* is expected to work
|
||||
* @param Db $connection
|
||||
* @return DbObject|string
|
||||
*/
|
||||
public function createDbObject(Db $connection)
|
||||
{
|
||||
if (!$this->isActionCreate()) {
|
||||
throw new RuntimeException('Only BranchActivity instances with action=create can create objects');
|
||||
}
|
||||
|
||||
$class = DbObjectTypeRegistry::classByType($this->getObjectTable());
|
||||
$object = $class::create();
|
||||
$object = $class::create([], $connection);
|
||||
$object->setUniqueId($this->getObjectUuid());
|
||||
foreach ($this->getModifiedProperties()->jsonSerialize() as $key => $value) {
|
||||
$object->set($key, $value);
|
||||
|
@ -130,7 +130,7 @@ class BranchMerger
|
||||
throw new MergeErrorRecreateOnMerge($activity);
|
||||
}
|
||||
} else {
|
||||
$activity->createDbObject()->store($this->connection);
|
||||
$activity->createDbObject($this->connection)->store($this->connection);
|
||||
}
|
||||
} elseif ($activity->isActionDelete()) {
|
||||
if ($exists) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user