Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Edit.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
11 
12 class Edit extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpGetActionInterface
13 {
17  public function execute()
18  {
19  $taxRuleId = $this->getRequest()->getParam('rule');
20  $this->_coreRegistry->register('tax_rule_id', $taxRuleId);
22  $backendSession = $this->_objectManager->get(\Magento\Backend\Model\Session::class);
23  if ($taxRuleId) {
24  try {
25  $taxRule = $this->ruleService->get($taxRuleId);
26  $pageTitle = sprintf("%s", $taxRule->getCode());
27  } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
28  $backendSession->unsRuleData();
29  $this->messageManager->addError(__('This rule no longer exists.'));
31  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
32  return $resultRedirect->setPath('tax/*/');
33  }
34  } else {
35  $pageTitle = __('New Tax Rule');
36  }
37  $data = $backendSession->getRuleData(true);
38  if (!empty($data)) {
39  $this->_coreRegistry->register('tax_rule_form_data', $data);
40  }
41  $breadcrumb = $taxRuleId ? __('Edit Rule') : __('New Rule');
42  $resultPage = $this->initResultPage();
43  $resultPage->addBreadcrumb($breadcrumb, $breadcrumb);
44  $resultPage->getConfig()->getTitle()->prepend(__('Tax Rules'));
45  $resultPage->getConfig()->getTitle()->prepend($pageTitle);
46  return $resultPage;
47  }
48 }
__()
Definition: __.php:13
$taxRule
Definition: tax_rule.php:35