mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-26 23:34:10 +02:00
parent
13e217c725
commit
50315d8714
@ -125,6 +125,9 @@ class ImportsourceController extends ActionController
|
||||
$this->addTitle('Clone: %s', $source->get('source_name'));
|
||||
$form = new CloneImportSourceForm($source);
|
||||
$this->content()->add($form);
|
||||
$form->on(CloneImportSourceForm::ON_SUCCESS, function (CloneImportSourceForm $form) {
|
||||
$this->getResponse()->redirectAndExit($form->getSuccessUrl());
|
||||
});
|
||||
$form->handleRequest($this->getServerRequest());
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ class ImportSource extends DbObjectWithSettings implements ExportInterface
|
||||
|
||||
public function setModifiers(array $modifiers)
|
||||
{
|
||||
if ($this->loadedRowModifiers === null) {
|
||||
if ($this->loadedRowModifiers === null && $this->hasBeenLoadedFromDb()) {
|
||||
$this->loadedRowModifiers = $this->fetchRowModifiers();
|
||||
}
|
||||
$current = $this->loadedRowModifiers;
|
||||
if (count($current) !== count($modifiers)) {
|
||||
if ($current !== null && count($current) !== count($modifiers)) {
|
||||
$this->newRowModifiers = $modifiers;
|
||||
} else {
|
||||
$i = 0;
|
||||
@ -394,7 +394,6 @@ class ImportSource extends DbObjectWithSettings implements ExportInterface
|
||||
public function fetchRowModifiers()
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$modifiers = ImportRowModifier::loadAll(
|
||||
$this->getConnection(),
|
||||
$db->select()
|
||||
@ -403,7 +402,11 @@ class ImportSource extends DbObjectWithSettings implements ExportInterface
|
||||
->order('priority ASC')
|
||||
);
|
||||
|
||||
return $modifiers;
|
||||
if ($modifiers) {
|
||||
return $modifiers;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
protected function fetchFlatRowModifiers()
|
||||
|
@ -52,13 +52,11 @@ class CloneImportSourceForm extends Form
|
||||
$newName = $this->getElement('source_name')->getValue();
|
||||
$export->source_name = $newName;
|
||||
unset($export->originalId);
|
||||
|
||||
if (ImportSource::existsWithName($newName, $this->source->getConnection())) {
|
||||
$this->getElement('source_name')->addMessage('Name already exists');
|
||||
}
|
||||
$this->newSource = ImportSource::import($export, $this->getTargetDb());
|
||||
$this->newSource->store();
|
||||
$this->redirectOnSuccess();
|
||||
}
|
||||
|
||||
public function getSuccessUrl()
|
||||
|
Loading…
x
Reference in New Issue
Block a user