Merge pull request #4032 from Icinga/feature/trigger-config-events-on-module-enable-and-disable

Trigger config events on enabling/disabling modules
This commit is contained in:
Johannes Meyer 2019-12-13 16:52:57 +01:00 committed by GitHub
commit c12da7b7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -160,6 +160,7 @@ class ConfigController extends Controller
$module = $form->getValue('identifier');
Icinga::app()->getModuleManager()->enableModule($module);
Notification::success(sprintf($this->translate('Module "%s" enabled'), $module));
$form->onSuccess();
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
});
@ -185,6 +186,7 @@ class ConfigController extends Controller
$module = $form->getValue('identifier');
Icinga::app()->getModuleManager()->disableModule($module);
Notification::success(sprintf($this->translate('Module "%s" disabled'), $module));
$form->onSuccess();
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
});

View File

@ -3,6 +3,7 @@
namespace Icinga\Forms;
use Icinga\Application\Hook\ConfigFormEventsHook;
use Icinga\Web\Form;
class ActionForm extends Form
@ -58,4 +59,20 @@ class ActionForm extends Form
]
);
}
public function isValid($formData)
{
$valid = parent::isValid($formData);
if ($valid) {
$valid = ConfigFormEventsHook::runIsValid($this);
}
return $valid;
}
public function onSuccess()
{
ConfigFormEventsHook::runOnSuccess($this);
}
}