You are here

public function LinkFormatter::settingsSummary in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::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

core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php, line 139

Class

LinkFormatter
Plugin implementation of the 'link' formatter.

Namespace

Drupal\link\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $settings = $this
    ->getSettings();
  if (!empty($settings['trim_length'])) {
    $summary[] = t('Link text trimmed to @limit characters', [
      '@limit' => $settings['trim_length'],
    ]);
  }
  else {
    $summary[] = t('Link text not trimmed');
  }
  if ($this
    ->getPluginId() == 'link' && !empty($settings['url_only'])) {
    if (!empty($settings['url_plain'])) {
      $summary[] = t('Show URL only as plain-text');
    }
    else {
      $summary[] = t('Show URL only');
    }
  }
  if (!empty($settings['rel'])) {
    $summary[] = t('Add rel="@rel"', [
      '@rel' => $settings['rel'],
    ]);
  }
  if (!empty($settings['target'])) {
    $summary[] = t('Open link in new window');
  }
  return $summary;
}