Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IgnoreTaxNotification.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
17  protected $_cacheTypeList;
18 
25  public function __construct(
26  \Magento\Backend\App\Action\Context $context,
27  \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService,
28  \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory,
29  \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
30  ) {
31  $this->_cacheTypeList = $cacheTypeList;
32  parent::__construct($context, $taxClassService, $taxClassDataObjectFactory);
33  }
34 
40  public function execute()
41  {
42  $section = $this->getRequest()->getParam('section');
43  if ($section) {
44  try {
45  $path = 'tax/notification/ignore_' . $section;
46  $this->_objectManager->get(\Magento\Config\Model\ResourceModel\Config::class)
47  ->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
48  } catch (\Exception $e) {
49  $this->messageManager->addError($e->getMessage());
50  }
51  }
52 
53  // clear the block html cache
54  $this->_cacheTypeList->cleanType('config');
55  $this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'config']);
56 
58  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
59  return $resultRedirect->setRefererUrl();
60  }
61 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService, \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList)