22 private $directoryData;
27 private $allowedCountriesReader;
37 $this->directoryData = $directoryData;
38 $this->allowedCountriesReader = $allowedCountriesReader;
62 $countryId =
$address->getCountryId();
65 $errors[] =
__(
'"%fieldName" is required. Enter and try again.', [
'fieldName' =>
'countryId']);
66 }
elseif (!in_array($countryId, $this->getWebsiteAllowedCountries(
$address),
true)) {
69 'Invalid value of "%value" provided for the %fieldName field.',
70 [
'fieldName' =>
'countryId',
'value' => htmlspecialchars($countryId)]
85 private function validateRegion(AbstractAddress
$address)
88 $countryId =
$address->getCountryId();
89 $countryModel =
$address->getCountryModel();
90 $regionCollection = $countryModel->getRegionCollection();
92 $regionId = (string)
$address->getRegionId();
93 $allowedRegions = $regionCollection->getAllIds();
94 $isRegionRequired = $this->directoryData->isRegionRequired($countryId);
95 if ($isRegionRequired && empty($allowedRegions) && !\
Zend_Validate::is($region,
'NotEmpty')) {
98 $errors[] =
__(
'"%fieldName" is required. Enter and try again.', [
'fieldName' =>
'region']);
102 $errors[] =
__(
'"%fieldName" is required. Enter and try again.', [
'fieldName' =>
'regionId']);
103 }
elseif ($allowedRegions && $regionId && !in_array($regionId, $allowedRegions,
true)) {
106 'Invalid value of "%value" provided for the %fieldName field.',
107 [
'fieldName' =>
'regionId',
'value' => htmlspecialchars($regionId)]
120 private function getWebsiteAllowedCountries(AbstractAddress
$address): array
123 return $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE,
$storeId);
elseif(isset( $params[ 'redirect_parent']))
__construct(Data $directoryData, AllowedCountries $allowedCountriesReader)
static is($value, $classBaseName, array $args=array(), $namespaces=array())
validate(AbstractAddress $address)