diff --git a/EventListeners/ConfigListener.php b/EventListeners/ConfigListener.php new file mode 100644 index 0000000..cd00e9c --- /dev/null +++ b/EventListeners/ConfigListener.php @@ -0,0 +1,52 @@ + ['onModuleConfigure', 128], + ]; +} + + public function onModuleConfigure(GenericEvent $event) + { + $subject = $event->getSubject(); + + if ($subject !== "HealthStatus") { + throw new \RuntimeException('Event subject does not match expected value'); + } + + $configModule = ModuleConfigQuery::create() + ->filterByModuleId(CmCIC::getModuleId()) + ->find(); + + $moduleConfig = []; + $path = __DIR__ . "/../" . CmCIC::JSON_CONFIG_PATH; + $moduleConfig = ['json_path' => is_readable($path) ? 'exists' : null]; + $configsCompleted = true; + if ($configModule->count() === 0) { + $configsCompleted = false; + } + $moduleConfig['module'] = CmCIC::getModuleCode(); + + foreach ($configModule as $config) { + $moduleConfig[$config->getName()] = $config->getValue(); + if ($config->getValue() === null) { + $configsCompleted = false; + } + } + + + $moduleConfig['completed'] = $configsCompleted; + + $event->setArgument('cmcic.module.config', $moduleConfig); + } +} \ No newline at end of file