diff --git a/application/forms/IcingaCloneObjectForm.php b/application/forms/IcingaCloneObjectForm.php index a5c8f2b39..d2f826cc4 100644 --- a/application/forms/IcingaCloneObjectForm.php +++ b/application/forms/IcingaCloneObjectForm.php @@ -148,7 +148,8 @@ public function onSuccess() $object->getObjectName() ); - if ($object->isTemplate() && $this->branch && $this->branch->isBranch()) { + $isBranch = $this->branch && $this->branch->isBranch(); + if ($object->isTemplate() && $isBranch) { throw new IcingaException('Cloning templates is not available for Branches'); } @@ -211,7 +212,11 @@ public function onSuccess() ); if ($new instanceof IcingaHost) { - $clone->set('host_id', $newId); + if ($isBranch) { + $clone->set('host', $newName); + } else { + $clone->set('host_id', $newId); + } } elseif ($new instanceof IcingaServiceSet) { $clone->set('service_set_id', $newId); } @@ -222,7 +227,14 @@ public function onSuccess() $newSet = IcingaServiceSet::fromPlainObject( $set->toPlainObject(), $connection - )->set('host_id', $newId); + ); + + if ($isBranch) { + $newSet->set('host', $newName); + } else { + $newSet->set('host_id', $newId); + } + $store->store($newSet); }