You are here

NominatimRoadFirstFormattingBase.php in Geolocation Field 8.3

File

modules/geolocation_leaflet/src/NominatimRoadFirstFormattingBase.php
View source
<?php

namespace Drupal\geolocation_leaflet;


/**
 * Alternative street formatting base class.
 *
 * Base class for nominatim geocoder country formatting plugins which use the
 * "<road> <house number>" address format.
 */
class NominatimRoadFirstFormattingBase extends NominatimCountryFormattingBase {

  /**
   * {@inheritdoc}
   */
  public function format(array $atomics) {
    $address_elements = parent::format($atomics);
    if (!empty($atomics['road'])) {
      $address_elements['addressLine1'] = $atomics['road'];
    }
    if (!empty($atomics['houseNumber'])) {
      $address_elements['addressLine1'] .= ' ' . $atomics['houseNumber'];
    }
    return $address_elements;
  }

}

Classes

Namesort descending Description
NominatimRoadFirstFormattingBase Alternative street formatting base class.