detailsFormatter = $detailsFormatter; $this->jsonSerializer = $jsonSerializer; } public function execute() { $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); if ($logEntryId = (int)$this->getRequest()->getParam('element_id')) { try { $data = $this->detailsFormatter->format($logEntryId); $result = [ 'isError' => false, 'data' => $data ]; } catch (\RuntimeException $e) { $result = [ 'isError' => true, 'message' => $e->getMessage() ]; } finally { $resultJson->setData($result); } } return $resultJson; } }