public function AddressService::getFormatter in Geocoder 8.2
Same name and namespace in other branches
- 8.3 modules/geocoder_address/src/AddressService.php \Drupal\geocoder_address\AddressService::getFormatter()
Set formatter.
The postal formatter seems to return the kind of value the geocoders expect to receive. Other situations might use the DefaultFormatter() instead.
Parameters
string $langcode: The langcode.
string $countrycode: The country code.
string $formatter: The type of formatter to return, 'postal' or 'default'.
Return value
mixed
- 'postal': \CommerceGuys\Addressing\Formatter\PostalLabelFormatter A formatter that will convert the input values into a postal label.
- 'default': \CommerceGuys\Addressing\Formatter\DefaultFormatter The default formatter.
1 call to AddressService::getFormatter()
- AddressService::addressArrayToGeoString in modules/
geocoder_address/ src/ AddressService.php - Convert an address array into a string address suitable for geocoding.
File
- modules/
geocoder_address/ src/ AddressService.php, line 78
Class
- AddressService
- Class AddressService.
Namespace
Drupal\geocoder_addressCode
public function getFormatter($langcode, $countrycode = 'US', $formatter = 'default') {
$default_options = [
'locale' => $langcode,
'origin_country' => $countrycode,
];
switch ($formatter) {
case 'postal':
return new PostalLabelFormatter($this->addressFormatRepository, $this->countryRepository, $this->subdivisionRepository, $default_options);
default:
return new DefaultFormatter($this->addressFormatRepository, $this->countryRepository, $this->subdivisionRepository, $default_options);
}
}