Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Backend.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Paypal\Helper;
7 
9 
14 {
18  protected $directoryHelper;
19 
23  protected $backendConfig;
24 
28  protected $scopeDefiner;
29 
36  public function __construct(
37  \Magento\Framework\App\Helper\Context $context,
38  \Magento\Directory\Helper\Data $directoryHelper,
40  \Magento\Config\Model\Config\ScopeDefiner $scopeDefiner
41  ) {
42  parent::__construct($context);
43  $this->directoryHelper = $directoryHelper;
44  $this->backendConfig = $backendConfig;
45  $this->scopeDefiner = $scopeDefiner;
46  }
47 
53  public function getConfigurationCountryCode()
54  {
55  $countryCode = $this->_request->getParam(\Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY);
56  if ($countryCode === null || preg_match('/^[a-zA-Z]{2}$/', $countryCode) == 0) {
57  $scope = $this->scopeDefiner->getScope();
59  $this->backendConfig->setData($scope, $this->_request->getParam($scope));
60  }
61  $countryCode = $this->backendConfig->getConfigDataValue(
62  \Magento\Paypal\Block\Adminhtml\System\Config\Field\Country::FIELD_CONFIG_PATH
63  );
64  }
65  if (empty($countryCode)) {
66  $countryCode = $this->directoryHelper->getDefaultCountry();
67  }
68  return $countryCode;
69  }
70 }
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Config\Model\Config $backendConfig, \Magento\Config\Model\Config\ScopeDefiner $scopeDefiner)
Definition: Backend.php:36