31 private $storeManager;
42 $this->scopeConfig = $scopeConfig;
55 $scope = ScopeInterface::SCOPE_WEBSITE,
58 if ($scopeCode ===
null) {
59 $scopeCode = $this->getDefaultScopeCode($scope);
63 case ScopeInterface::SCOPE_WEBSITES:
64 case ScopeInterface::SCOPE_STORES:
65 $allowedCountries = [];
66 foreach ($scopeCode as $singleFilter) {
67 $allowedCountries = array_merge(
87 private function getDefaultScopeCode($scope)
90 case ScopeInterface::SCOPE_WEBSITE:
91 return $this->storeManager->getWebsite()->getId();
92 case ScopeInterface::SCOPE_STORE:
93 return $this->storeManager->getStore()->getId();
94 case ScopeInterface::SCOPE_GROUP:
95 return $this->storeManager->getGroup()->getId();
96 case ScopeInterface::SCOPE_WEBSITES:
97 return [$this->storeManager->getWebsite()->getId()];
98 case ScopeInterface::SCOPE_STORES:
99 return [$this->storeManager->getStore()->getId()];
101 throw new \InvalidArgumentException(
"Invalid scope is specified");
114 return array_combine($allowedCountries, $allowedCountries);
129 (
string) $this->scopeConfig->getValue(
130 self::ALLOWED_COUNTRIES_PATH,
143 private function getSingleScope($scope)
145 if ($scope == ScopeInterface::SCOPE_WEBSITES) {
146 return ScopeInterface::SCOPE_WEBSITE;
149 if ($scope == ScopeInterface::SCOPE_STORES) {
150 return ScopeInterface::SCOPE_STORE;
getAllowedCountries( $scope=ScopeInterface::SCOPE_WEBSITE, $scopeCode=null)
makeCountriesUnique(array $allowedCountries)
__construct(ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager)
getCountriesFromConfig($scope, $scopeCode)
const ALLOWED_COUNTRIES_PATH