You are here

public function GeolocationMapFormatterBase::settingsSummary in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldFormatter/GeolocationMapFormatterBase.php \Drupal\geolocation\Plugin\Field\FieldFormatter\GeolocationMapFormatterBase::settingsSummary()

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/GeolocationMapFormatterBase.php, line 266

Class

GeolocationMapFormatterBase
Plugin base for Map based formatters.

Namespace

Drupal\geolocation\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $settings = $this
    ->getSettings();
  $summary = [];
  $summary[] = $this
    ->t('Marker set: @marker', [
    '@marker' => $settings['set_marker'] ? $this
      ->t('Yes') : $this
      ->t('No'),
  ]);
  if ($settings['set_marker']) {
    $summary[] = $this
      ->t('Marker Title: @type', [
      '@type' => $settings['title'],
    ]);
    if (!empty($settings['info_text']['value']) && !empty($settings['info_text']['format'])) {
      $summary[] = $this
        ->t('Marker Info Text: @type', [
        '@type' => current(explode(chr(10), wordwrap(check_markup($settings['info_text']['value'], $settings['info_text']['format']), 30))),
      ]);
    }
    if (!empty($settings['common_map'])) {
      $summary[] = $this
        ->t('Common Map Display: Yes');
    }
  }
  if ($this->mapProvider) {
    $summary = array_replace_recursive($summary, $this->mapProvider
      ->getSettingsSummary($settings['map_provider_settings']));
  }
  else {
    $summary[] = $this
      ->t('Attention: No map provider set!');
  }
  return $summary;
}