directoryCountry = $directoryCountry; $this->directoryRegion = $directoryRegion; } /** * @inheritDoc */ public function getRegions(): array { return [ [ 'value' => self::ALL, 'label' => __('Show to all site visitors'), ], [ 'value' => self::EU, 'label' => __('Only visitors from EU countries'), ], [ 'value' => self::UNKNOWN, 'label' => __('Unknown'), ], ]; } /** * @inheritDoc */ public function getCountries(): array { return $this->directoryCountry->toOptionArray(true); } /** * @inheritDoc */ public function getCountryStates(string $countryName): array { $allRegions = $this->directoryRegion->toOptionArray(); $result = []; foreach ($allRegions as $region) { if ($region['label'] === $countryName) { $regionOptions = $region['value']; $result[] = [ 'value' => self::ALL, 'label' => __('Show to all states') ]; foreach ($regionOptions as $regionOption) { $result[] = [ 'value' => $regionOption['label'], 'label' => $regionOption['label'] ]; } break; } } return $result; } }