You are here

public function SimpleGMapFormatter::settingsSummary in Simple Google Maps 8

Same name and namespace in other branches
  1. 3.0.x src/Plugin/Field/FieldFormatter/SimpleGMapFormatter.php \Drupal\simple_gmap\Plugin\Field\FieldFormatter\SimpleGMapFormatter::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/SimpleGMapFormatter.php, line 184

Class

SimpleGMapFormatter
Plugin implementation of the 'simple_gmap' formatter.

Namespace

Drupal\simple_gmap\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $map_types = [
    'm' => $this
      ->t('Map'),
    'k' => $this
      ->t('Satellite'),
    'h' => $this
      ->t('Hybrid'),
    'p' => $this
      ->t('Terrain'),
  ];
  $map_type = $this
    ->getSetting('map_type') ? $this
    ->getSetting('map_type') : 'm';
  $map_type = isset($map_types[$map_type]) ? $map_types[$map_type] : $map_types['m'];
  $include_map = $this
    ->getSetting('include_map');
  if ($include_map) {
    $summary[] = $this
      ->t('Dynamic map: @width x @height', [
      '@width' => $this
        ->getSetting('iframe_width'),
      '@height' => $this
        ->getSetting('iframe_height'),
    ]);
    $summary[] = $this
      ->t('Title of the iframe: @title', [
      '@title' => $this
        ->getSetting('iframe_title'),
    ]);
  }
  $include_static_map = $this
    ->getSetting('include_static_map');
  if ($include_static_map) {
    $summary[] = $this
      ->t('Static map: @width x @height, Scale: @static_scale', [
      '@width' => $this
        ->getSetting('iframe_width'),
      '@height' => $this
        ->getSetting('iframe_height'),
      '@static_scale' => $this
        ->getSetting('static_scale'),
    ]);
  }
  $include_link = $this
    ->getSetting('include_link');
  if ($include_link) {
    $summary[] = $this
      ->t('Map link: @link_text', [
      '@link_text' => $this
        ->getSetting('link_text'),
    ]);
  }
  if ($include_link || $include_map || $include_static_map) {
    $summary[] = $this
      ->t('Map Type: @map_type', [
      '@map_type' => $map_type,
    ]);
    $summary[] = $this
      ->t('Zoom Level: @zoom_level', [
      '@zoom_level' => $this
        ->getSetting('zoom_level'),
    ]);
    $summary[] = $this
      ->t('Language: @language', [
      '@language' => $this
        ->getSetting('langcode'),
    ]);
  }
  $include_text = $this
    ->getSetting('include_text');
  if ($include_text) {
    $summary[] = $this
      ->t('Original text displayed');
  }
  return $summary;
}