Validate.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Controller\Adminhtml\System\Config\Validatevat;
  7. use Magento\Framework\Controller\Result\JsonFactory;
  8. class Validate extends \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat
  9. {
  10. /**
  11. * @var JsonFactory
  12. */
  13. protected $resultJsonFactory;
  14. /**
  15. * @param \Magento\Backend\App\Action\Context $context
  16. * @param JsonFactory $resultJsonFactory
  17. */
  18. public function __construct(
  19. \Magento\Backend\App\Action\Context $context,
  20. JsonFactory $resultJsonFactory
  21. ) {
  22. parent::__construct($context);
  23. $this->resultJsonFactory = $resultJsonFactory;
  24. }
  25. /**
  26. * Check whether vat is valid
  27. *
  28. * @return \Magento\Framework\Controller\Result\Json
  29. */
  30. public function execute()
  31. {
  32. $result = $this->_validate();
  33. /** @var \Magento\Framework\Controller\Result\Json $resultJson */
  34. $resultJson = $this->resultJsonFactory->create();
  35. return $resultJson->setData([
  36. 'valid' => (int)$result->getIsValid(),
  37. 'message' => $result->getRequestMessage(),
  38. ]);
  39. }
  40. }