You are here

public function Address::preprocess in Geocoder 8.3

Same name and namespace in other branches
  1. 8.2 modules/geocoder_address/src/Plugin/Geocoder/Preprocessor/Address.php \Drupal\geocoder_address\Plugin\Geocoder\Preprocessor\Address::preprocess()

Processes the values of the field before geocoding.

Return value

$this

Overrides PreprocessorBase::preprocess

File

modules/geocoder_address/src/Plugin/Geocoder/Preprocessor/Address.php, line 65

Class

Address
Provides a geocoder preprocessor plugin for address fields.

Namespace

Drupal\geocoder_address\Plugin\Geocoder\Preprocessor

Code

public function preprocess() {
  parent::preprocess();
  foreach ($this->field
    ->getValue() as $delta => $value) {
    $address = '';

    // Use the Address API to format the array of values into a string
    // that can be sent to the geocoder service.
    if (is_array($value)) {
      $address = $this->addressService
        ->addressArrayToGeoString($value);
    }
    $value['value'] = $address;
    $this->field
      ->set($delta, $value);
  }
  return $this;
}