Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Delete.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
17  public function execute()
18  {
20  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
21  $ruleId = (int)$this->getRequest()->getParam('rule');
22  try {
23  $this->ruleService->deleteById($ruleId);
24  $this->messageManager->addSuccess(__('The tax rule has been deleted.'));
25  return $resultRedirect->setPath('tax/*/');
26  } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
27  $this->messageManager->addError(__('This rule no longer exists.'));
28  return $resultRedirect->setPath('tax/*/');
29  } catch (\Magento\Framework\Exception\LocalizedException $e) {
30  $this->messageManager->addError($e->getMessage());
31  } catch (\Exception $e) {
32  $this->messageManager->addError(__('Something went wrong deleting this tax rule.'));
33  }
34 
35  return $resultRedirect->setUrl($this->_redirect->getRedirectUrl($this->getUrl('*')));
36  }
37 }
__()
Definition: __.php:13