Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AjaxDelete.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
19  public function execute()
20  {
21  $classId = (int)$this->getRequest()->getParam('class_id');
22  try {
23  $this->taxClassRepository->deleteById($classId);
24  $responseContent = ['success' => true, 'error_message' => ''];
25  } catch (\Magento\Framework\Exception\LocalizedException $e) {
26  $responseContent = ['success' => false, 'error_message' => $e->getMessage()];
27  } catch (\Exception $e) {
28  $responseContent = [
29  'success' => false,
30  'error_message' => __('We can\'t delete this tax class right now.')
31  ];
32  }
33 
35  $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
36  $resultJson->setData($responseContent);
37  return $resultJson;
38  }
39 }
__()
Definition: __.php:13