You are here

public function StyledGoogleMapDefaultFormatter::settingsSummary in Styled Google Map 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/StyledGoogleMapDefaultFormatter.php \Drupal\styled_google_map\Plugin\Field\FieldFormatter\StyledGoogleMapDefaultFormatter::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/StyledGoogleMapDefaultFormatter.php, line 554

Class

StyledGoogleMapDefaultFormatter
Plugin implementation of the 'styled_google_map_default' formatter.

Namespace

Drupal\styled_google_map\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $summary[] = $this
    ->t('Width: <b>%width</b><br />Height: <b>%height</b>', [
    '%width' => $this
      ->getSetting('width'),
    '%height' => $this
      ->getSetting('height'),
  ]);
  $style_settings = $this
    ->getSetting('style');
  if ($style_settings['style']) {
    $summary[] = $this
      ->t('<br />Map style: <b>Custom</b>');
  }
  if ($style_settings['pin']) {
    $summary[] = $this
      ->t('<br />Pin style: <b>%pin</b>', [
      '%pin' => $style_settings['pin'],
    ]);
  }
  $summary[] = $this
    ->t('<br />Map type: <b>%maptype</b>', [
    '%maptype' => $style_settings['maptype'],
  ]);
  if ($style_settings['pin']) {
    $summary[] = $this
      ->t('<br />Pin location: <b>%pin</b>', [
      '%pin' => $style_settings['pin'],
    ]);
  }
  $popup_settings = $this
    ->getSetting('popup');
  if ($popup_settings['choice'] == 1) {
    $summary[] = $this
      ->t('<br />Popup shows field <b>%field</b>', [
      '%field' => $popup_settings['text'],
    ]);
    $readable = [
      FALSE => $this
        ->t('without'),
      TRUE => $this
        ->t('with'),
    ];
    $summary[] = $this
      ->t('<b>%label</b> label', [
      '%label' => $readable[$popup_settings['label']],
    ]);
  }
  if ($popup_settings['choice'] == 2) {
    $summary[] = $this
      ->t('<br />Popup shows view mode <b>%viewmode</b>', [
      '%viewmode' => $popup_settings['view_mode'],
    ]);
  }
  $zoom_settings = $this
    ->getSetting('zoom');
  $summary[] = $this
    ->t('<br />Default zoom: <b>%zoom</b>', [
    '%zoom' => $zoom_settings['default'],
  ]);
  $summary[] = $this
    ->t('<br />Maximum zoom: <b>%maxzoom</b>', [
    '%maxzoom' => $zoom_settings['max'],
  ]);
  $summary[] = $this
    ->t('<br />Minimum zoom: <b>%minzoom</b>', [
    '%minzoom' => $zoom_settings['min'],
  ]);
  $gesture_handling = $this
    ->getSetting('gestureHandling');
  $summary[] = $this
    ->t('<br />Gesture handling:<b>%mode</b>', [
    '%mode' => $gesture_handling,
  ]);
  $directions_settings = $this
    ->getSetting('directions');
  if ($directions_settings['enabled']) {
    $summary[] = $this
      ->t('<br />Getting directions option is enabled with such settings:');
    $summary[] = $this
      ->t('<br />Directions travel mode: <b>%mode</b>', [
      '%mode' => $directions_settings['type'],
    ]);
    $summary[] = $this
      ->t('<br />Show detailed steps: <b>%steps</b>', [
      '%steps' => $directions_settings['steps'] ? $this
        ->t('Yes') : $this
        ->t('No'),
    ]);
  }
  return $summary;
}