fileFactory = $fileFactory; $this->fileDriver = $fileDriver; $this->fileSystem = $fileSystem; $this->timezone = $timezone; parent::__construct($context); } public function execute() { $today = $this->timezone->date()->format('d-m-Y'); $date = $this->getRequest()->getParam('date'); $logfile = $this->getRequest()->getParam('logfile'); if ($date == "") { $date = $today; } if ($logfile == '') { $this->messageManager->addErrorMessage(__('Please select log first and try again!')); $this->_redirect('caratlane/logviewer/index'); return; } $filePath = IntegrationConstants::NETSUITE_LOG_DIR.$date.'/'.$logfile; $varDir = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR); $fileAbsolutePath = $varDir->getAbsolutePath($filePath); if ($this->fileDriver->isExists($fileAbsolutePath)) { $content['type'] = 'filename'; $content['value'] = $fileAbsolutePath; $content['rm'] = 0; return $this->fileFactory->create($logfile, $content, DirectoryList::VAR_DIR); } else { $this->messageManager->addErrorMessage(__('Log file not exist!')); $this->_redirect('caratlane/logviewer/index'); return; } } /** * @return bool */ protected function _isAllowed() { return $this->_authorization->isAllowed(static::MENU_ID); } }