Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ValidateAdvanced.php
Go to the documentation of this file.
1 <?php
8 
10 {
14  protected $resultJsonFactory;
15 
20  public function __construct(
21  \Magento\Backend\App\Action\Context $context,
22  \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
23  ) {
24  parent::__construct($context);
25  $this->resultJsonFactory = $resultJsonFactory;
26  }
27 
33  public function execute()
34  {
35  $result = $this->_validate();
36  $valid = $result->getIsValid();
37  $success = $result->getRequestSuccess();
38  // ID of the store where order is placed
39  $storeId = $this->getRequest()->getParam('store_id');
40  // Sanitize value if needed
41  if ($storeId !== null) {
42  $storeId = (int)$storeId;
43  }
44 
45  $groupId = $this->_objectManager->get(\Magento\Customer\Model\Vat::class)
46  ->getCustomerGroupIdBasedOnVatNumber(
47  $this->getRequest()->getParam('country'),
48  $result,
49  $storeId
50  );
51 
53  $resultJson = $this->resultJsonFactory->create();
54  return $resultJson->setData(['valid' => $valid, 'group' => $groupId, 'success' => $success]);
55  }
56 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory)