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 @@ + + + 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); + } +}