geolocation-8.x-3.x-dev/modules/geolocation_google_maps/src/Plugin/geolocation/GeocoderCountryFormatting/Switzerland.php

modules/geolocation_google_maps/src/Plugin/geolocation/GeocoderCountryFormatting/Switzerland.php
<?php

namespace Drupal\geolocation_google_maps\Plugin\geolocation\GeocoderCountryFormatting;

use Drupal\geolocation\Attribute\GeocoderCountryFormatting;
use Drupal\geolocation_google_maps\GoogleCountryFormattingBase;

/**
 * Provides address formatting.
 */
#[GeocoderCountryFormatting(
  id: 'google_ch',
  countryCode: 'ch',
  geocoder: 'google_geocoding_api'
)]
class Switzerland extends GoogleCountryFormattingBase {

  /**
   * {@inheritdoc}
   */
  public function format(array $atomics): ?array {
    $address_elements = parent::format($atomics);
    if (
      isset($atomics['streetNumber'])
      && $atomics['streetNumber']
      && isset($atomics['route'])
      && $atomics['route']
    ) {
      $address_elements['addressLine1'] = $atomics['route'] . ' ' . $atomics['streetNumber'];
    }

    return $address_elements;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc