You are here

public function SmartTrimFormatter::settingsSummary in Smart Trim 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/SmartTrimFormatter.php, line 194

Class

SmartTrimFormatter
Plugin implementation of the 'smart_trim' formatter.

Namespace

Drupal\smart_trim\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $type = $this
    ->t('words');
  if ($this
    ->getSetting('trim_type') == 'chars') {
    $type = $this
      ->t('characters');
  }
  $trim_string = $this
    ->getSetting('trim_length') . ' ' . $type;
  if (mb_strlen(trim($this
    ->getSetting('trim_suffix')))) {
    $trim_string .= " " . $this
      ->t("with suffix");
  }
  if ($this
    ->getSetting('more_link')) {
    $trim_string .= ", " . $this
      ->t("with more link");
  }
  $summary[] = $trim_string;
  return $summary;
}