From 16fbf6d7bd4911580739e6e56a02690dec6873e7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 12 Jul 2019 10:23:49 +0200 Subject: [PATCH] Introduce ConfigFormEventsHook --- .../Application/Hook/ConfigFormEventsHook.php | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 library/Icinga/Application/Hook/ConfigFormEventsHook.php diff --git a/library/Icinga/Application/Hook/ConfigFormEventsHook.php b/library/Icinga/Application/Hook/ConfigFormEventsHook.php new file mode 100644 index 000000000..7f625533e --- /dev/null +++ b/library/Icinga/Application/Hook/ConfigFormEventsHook.php @@ -0,0 +1,137 @@ +runAppliesTo($form)) { + continue; + } + + try { + $hook->$eventMethod($form); + } catch (\Exception $e) { + static::$lastErrors[] = $e->getMessage(); + + Logger::error("%s\n%s", $e, IcingaException::getConfidentialTraceAsString($e)); + + $success = false; + } + } + + return $success; + } + + private function runAppliesTo(ConfigForm $form) + { + try { + $appliesTo = $this->appliesTo($form); + } catch (\Exception $e) { + // Don't save exception to last errors because we do not want to disturb the user for messed up + // appliesTo checks + Logger::error("%s\n%s", $e, IcingaException::getConfidentialTraceAsString($e)); + + $appliesTo = false; + } + + return $appliesTo === true; + } +}