Use ConfigFormEventsHook

This commit is contained in:
Eric Lippmann 2019-07-12 10:24:07 +02:00 committed by Johannes Meyer
parent 16fbf6d7bd
commit 6bb285f7b5
1 changed files with 23 additions and 0 deletions

View File

@ -4,6 +4,7 @@
namespace Icinga\Forms;
use Exception;
use Icinga\Application\Hook\ConfigFormEventsHook;
use Icinga\Exception\ConfigurationError;
use Zend_Form_Decorator_Abstract;
use Icinga\Application\Config;
@ -52,6 +53,21 @@ class ConfigForm extends Form
return $this;
}
public function isValid($formData)
{
$valid = parent::isValid($formData);
if ($valid && ConfigFormEventsHook::runIsValid($this) === false) {
foreach (ConfigFormEventsHook::getLastErrors() as $msg) {
$this->error($msg);
}
$valid = false;
}
return $valid;
}
/**
* {@inheritdoc}
*/
@ -72,6 +88,13 @@ class ConfigForm extends Form
} else {
return false;
}
if (ConfigFormEventsHook::runOnSuccess($this) === false) {
Notification::error($this->translate(
'Configuration successfully stored. Though, one or more module hooks failed to run.'
. ' See logs for details'
));
}
}
/**