You are here

public function GoogleGeocodingAPI::formProcessInput in Geolocation Field 8

Process from as altered above.

Parameters

array $input: Input values.

string $element_name: Name of the input element.

Return value

array|bool Location data.

Overrides GeocoderBase::formProcessInput

File

src/Plugin/geolocation/Geocoder/GoogleGeocodingAPI.php, line 166

Class

GoogleGeocodingAPI
Provides the Google Geocoding API.

Namespace

Drupal\geolocation\Plugin\geolocation\Geocoder

Code

public function formProcessInput(array &$input, $element_name) {
  if (!empty($input['geolocation_geocoder_google_geocoding_api']) && empty($input['geolocation_geocoder_google_geocoding_api_state'])) {
    $location_data = $this
      ->geocode($input['geolocation_geocoder_google_geocoding_api']);
    if (empty($location_data)) {
      $input['geolocation_geocoder_google_geocoding_api_state'] = 0;
      return FALSE;
    }
    $input['geolocation_geocoder_google_geocoding_api'] = $location_data['address'];
    $input['geolocation_geocoder_google_geocoding_api_state'] = 1;
    return $location_data;
  }
  return TRUE;
}