You are here

public function HMSNaturalLanguageFormatter::settingsSummary in HMS Field 8

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/HMSNaturalLanguageFormatter.php, line 110
Contains \Drupal\hms_field\Plugin\Field\FieldFormatter\HMSNaturalLanguageFormatter.

Class

HMSNaturalLanguageFormatter
Plugin implementation of the 'hms_natural_language_formatter' formatter.

Namespace

Drupal\hms_field\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = array();
  $factors = $this->hms_service
    ->factor_map(TRUE);
  $fragments = $this
    ->getSetting('display_formats');
  $fragment_list = array();
  foreach ($fragments as $fragment) {
    if ($fragment) {
      $fragment_list[] = t($factors[$fragment]['label multiple']);
    }
  }
  $summary[] = t('Displays: @display', array(
    '@display' => implode(', ', $fragment_list),
  ));
  $summary[] = t('Separator: \'@separator\'', array(
    '@separator' => $this
      ->getSetting('separator'),
  ));
  if (strlen($this
    ->getSetting('last_separator'))) {
    $summary[] = t('Last Separator: \'@last_separator\'', array(
      '@last_separator' => $this
        ->getSetting('last_separator'),
    ));
  }
  return $summary;
}