<?php
namespace VendorModuleControllerAdminhtmlModule;
use MagentoBackendAppAction;
use MagentoTestFrameworkErrorLogLogger;
class DeleteRow extends MagentoBackendAppAction
{
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Vendor_Module::route_id');
}
public function execute()
{
$id = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();
if ($id) {
try {
$model = $this->_objectManager->create('VendorModuleModelModule');
$model->load($id);
$model->delete();
$this->messageManager->addSuccess(__('The Record has been deleted.'));
return $resultRedirect->setPath('*/*/');
} catch (Exception $e) {
$this->messageManager->addError($e->getMessage());
return $resultRedirect->setPath('*/*/edit', ['entity_id' => $id]);
}
}
$this->messageManager->addError(__('We can't find a row to delete.'));
return $resultRedirect->setPath('*/*/');
}
}
?>