diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /application/forms/ImportCheckForm.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/ImportCheckForm.php')
-rw-r--r-- | application/forms/ImportCheckForm.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/application/forms/ImportCheckForm.php b/application/forms/ImportCheckForm.php new file mode 100644 index 0000000..31c9781 --- /dev/null +++ b/application/forms/ImportCheckForm.php @@ -0,0 +1,50 @@ +<?php + +namespace Icinga\Module\Director\Forms; + +use Icinga\Module\Director\Objects\ImportSource; +use Icinga\Module\Director\Web\Form\DirectorForm; + +class ImportCheckForm extends DirectorForm +{ + /** @var ImportSource */ + protected $source; + + public function setImportSource(ImportSource $source) + { + $this->source = $source; + return $this; + } + + public function setup() + { + $this->submitLabel = false; + $this->addElement('submit', 'submit', [ + 'label' => $this->translate('Check for changes'), + 'decorators' => ['ViewHelper'] + ]); + } + + public function onSuccess() + { + $source = $this->source; + if ($source->checkForChanges()) { + $this->setSuccessMessage( + $this->translate('This Import Source provides modified data') + ); + } else { + $this->setSuccessMessage( + $this->translate( + 'Nothing to do, data provided by this Import Source' + . " didn't change since the last import run" + ) + ); + } + + if ($source->get('import_state') === 'failing') { + $this->addError($this->translate('Checking this Import Source failed')); + } else { + parent::onSuccess(); + } + } +} |