redirectFactory->create(); $result->setPath('*/*/index'); $id = (int) $this->getRequest()->getParam('id'); $file = $this->fileFactory->create(); $this->fileResource->load($file, $id); if (!$file->getId()) { $this->messageManager->addErrorMessage(__('The file record no longer exists.')); return $result; } try { $this->deleteService->delete($file); $this->messageManager->addSuccessMessage(__('The file has been deleted.')); } catch (\Throwable $exception) { $this->messageManager->addErrorMessage($exception->getMessage()); } return $result; } }