/** * 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) { switch ($change['type']) { case Config::ENABLED: $modelData = ['type' => Config::MODULE_ENABLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)]; break; case Config::DISABLED: $modelData = ['type' => Config::MODULE_DISABLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)]; break; case Config::INSTALLED: $modelData = ['type' => Config::MODULE_INSTALLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)]; break; case Config::UNINSTALLED: $modelData = ['type' => Config::MODULE_UNINSTALLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)]; break; } /** @var \Magento\NewRelicReporting\Model\System $systemModel */ $systemModel = $this->systemFactory->create(); $systemModel->setData($modelData); $systemModel->save(); } } } return $this; }
/** * Reports a system cache flush to the database reporting_system_updates table * * @param Observer $observer * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute(Observer $observer) { if ($this->config->isNewRelicEnabled()) { $jsonData = ['status' => 'updated']; $modelData = ['type' => Config::FLUSH_CACHE, 'action' => $this->jsonEncoder->encode($jsonData)]; /** @var \Magento\NewRelicReporting\Model\System $systemModel */ $systemModel = $this->systemFactory->create(); $systemModel->setData($modelData); $systemModel->save(); } }
/** * Reports any products deleted to the database reporting_system_updates table * * @param Observer $observer * @return void */ public function execute(Observer $observer) { if ($this->config->isNewRelicEnabled()) { /** @var \Magento\Catalog\Model\Product $product */ $product = $observer->getEvent()->getProduct(); $jsonData = ['id' => $product->getId(), 'status' => 'deleted']; $modelData = ['type' => Config::PRODUCT_CHANGE, 'action' => $this->jsonEncoder->encode($jsonData), 'updated_at' => $this->dateTime->formatDate(true)]; /** @var \Magento\NewRelicReporting\Model\System $systemModel */ $systemModel = $this->systemFactory->create(); $systemModel->setData($modelData); $systemModel->save(); } }
/** * Reports any products created or updated to the database reporting_system_updates table * * @param Observer $observer * @return void */ public function execute(Observer $observer) { if ($this->config->isNewRelicEnabled()) { /** @var \Magento\Catalog\Model\Product $product */ $product = $observer->getEvent()->getProduct(); $jsonData = ['name' => $product->getName()]; if ($product->isObjectNew()) { $jsonData['status'] = 'created'; } else { $jsonData['id'] = $product->getId(); $jsonData['status'] = 'updated'; } $modelData = ['type' => Config::PRODUCT_CHANGE, 'action' => $this->jsonEncoder->encode($jsonData)]; /** @var \Magento\NewRelicReporting\Model\System $systemModel */ $systemModel = $this->systemFactory->create(); $systemModel->setData($modelData); $systemModel->save(); } }