config = $config; $this->collect = $collect; $this->systemFactory = $systemFactory; $this->jsonEncoder = $jsonEncoder; } /** * Reports Modules and module changes to the database reporting_module_status table * * @return \Magento\NewRelicReporting\Model\Cron\ReportModulesInfo */ public function report() { if ($this->config->isNewRelicEnabled()) { $moduleData = $this->collect->getModuleData(); if (count($moduleData['changes']) > 0) { foreach ($moduleData['changes'] as $change) { $modelData = []; switch ($change['type']) { case Config::ENABLED: $modelData = [ 'type' => Config::MODULE_ENABLED, 'action' => $this->jsonEncoder->encode($change), ]; break; case Config::DISABLED: $modelData = [ 'type' => Config::MODULE_DISABLED, 'action' => $this->jsonEncoder->encode($change), ]; break; case Config::INSTALLED: $modelData = [ 'type' => Config::MODULE_INSTALLED, 'action' => $this->jsonEncoder->encode($change), ]; break; case Config::UNINSTALLED: $modelData = [ 'type' => Config::MODULE_UNINSTALLED, 'action' => $this->jsonEncoder->encode($change), ]; break; } /** @var \Magento\NewRelicReporting\Model\System $systemModel */ $systemModel = $this->systemFactory->create(); $systemModel->setData($modelData); $systemModel->save(); } } } return $this; } }