configFactory = $configFactory; $this->productMetadata = $productMetadata; $this->notificationLogger = $notificationLogger; } /** * Change the value of config/admin/usage/enabled */ private function enableAdminUsage() { $configModel = $this->configFactory->create(); $configModel->setDataByPath('admin/usage/enabled', 1); $configModel->save(); } /** * Log information about the last user response * * @return ResultInterface */ private function markUserNotified(): ResultInterface { $responseContent = [ 'success' => $this->notificationLogger->log( $this->productMetadata->getVersion() ), 'error_message' => '' ]; $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); return $resultJson->setData($responseContent); } /** * Log information about the last shown advertisement * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $this->enableAdminUsage(); return $this->markUserNotified(); } /** * @inheritDoc */ protected function _isAllowed() { return $this->_authorization->isAllowed(static::ADMIN_RESOURCE); } }