From 4518f777fef5c546ef50fb0b3cba268afd20dc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Laissus?= Date: Thu, 18 Apr 2024 15:45:03 +0200 Subject: [PATCH 1/2] feat: add configListener and update config.xml for Health Check --- Listener/ConfigListener.php | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Listener/ConfigListener.php diff --git a/Listener/ConfigListener.php b/Listener/ConfigListener.php new file mode 100644 index 000000000..b4a941267 --- /dev/null +++ b/Listener/ConfigListener.php @@ -0,0 +1,52 @@ + [ + 'onModuleConfig', 128 + ], + ]; + } + + public function onModuleConfig(GenericEvent $event): void + { + $subject = $event->getSubject(); + + if ($subject !== "HealthStatus") { + throw new \RuntimeException('Event subject does not match expected value'); + } + + $configModule = ModuleConfigQuery::create() + ->filterByModuleId(Cheque::getModuleId()) + ->find(); + + $moduleConfig = []; + $moduleConfig['module'] = Cheque::getModuleCode(); + $configsCompleted = true; + + if ($configModule->count() === 0) { + $configsCompleted = false; + } + + foreach ($configModule as $config) { + $moduleConfig[$config->getName()] = $config->getValue(); + if ($config->getValue() === null) { + $configsCompleted = false; + } + } + + $moduleConfig['completed'] = $configsCompleted; + + $event->setArgument('cheque.module.config', $moduleConfig); + } +} From 7542fcd83828af28bf2e532832f05faf33af0669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Laissus?= Date: Thu, 18 Apr 2024 15:46:24 +0200 Subject: [PATCH 2/2] update config.xml --- Config/config.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Config/config.xml b/Config/config.xml index b09cf496b..646d94619 100644 --- a/Config/config.xml +++ b/Config/config.xml @@ -20,6 +20,9 @@ + + +