productMetadata = $productMetadata; $this->notificationLogger = $notificationLogger; $this->logger = $logger; } /** * Log information about the last shown advertisement * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { try { $responseContent = [ 'success' => $this->notificationLogger->log( $this->_auth->getUser()->getId(), $this->productMetadata->getVersion() ), 'error_message' => '' ]; } catch (LocalizedException $e) { $this->logger->error($e->getMessage()); $responseContent = [ 'success' => false, 'error_message' => $e->getMessage() ]; } catch (\Exception $e) { $this->logger->error($e->getMessage()); $responseContent = [ 'success' => false, 'error_message' => __('It is impossible to log user action') ]; } $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); return $resultJson->setData($responseContent); } /** * @return bool */ protected function _isAllowed() { return parent::_isAllowed(); } }