![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-payment/Gateway/Validator/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Payment\Gateway\Validator; use Magento\Framework\Exception\NotFoundException; use Magento\Payment\Gateway\ConfigInterface; use Magento\Payment\Gateway\Validator\ResultInterfaceFactory; /** * @api * @since 100.0.2 */ class CountryValidator extends AbstractValidator { /** * @var \Magento\Payment\Gateway\ConfigInterface */ private $config; /** * @param ResultInterfaceFactory $resultFactory * @param \Magento\Payment\Gateway\ConfigInterface $config */ public function __construct( ResultInterfaceFactory $resultFactory, ConfigInterface $config ) { $this->config = $config; parent::__construct($resultFactory); } /** * Validate country * * @param array $validationSubject * @return bool * @throws NotFoundException * @throws \Exception */ public function validate(array $validationSubject) { $isValid = true; $storeId = $validationSubject['storeId']; if ((int)$this->config->getValue('allowspecific', $storeId) === 1) { $availableCountries = explode( ',', $this->config->getValue('specificcountry', $storeId) ?? '' ); if (!in_array($validationSubject['country'], $availableCountries)) { $isValid = false; } } return $this->createResult($isValid); } }