You are here

public function MiconLinkFormatter::settingsSummary in Micon 8

Same name and namespace in other branches
  1. 2.x micon_link/src/Plugin/Field/FieldFormatter/MiconLinkFormatter.php \Drupal\micon_link\Plugin\Field\FieldFormatter\MiconLinkFormatter::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 LinkFormatter::settingsSummary

File

micon_link/src/Plugin/Field/FieldFormatter/MiconLinkFormatter.php, line 75

Class

MiconLinkFormatter
Plugin implementation of the 'micon_link' formatter.

Namespace

Drupal\micon_link\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $settings = $this
    ->getSettings();
  if (!empty($settings['title'])) {
    $summary[] = t('Link title as @title', [
      '@title' => $settings['title'],
    ]);
  }
  if (!empty($settings['icon'])) {
    $summary[] = $this
      ->micon('Icon as')
      ->setIcon($settings['icon'])
      ->setIconAfter();
  }
  if (!empty($settings['position'])) {
    $summary[] = t('Icon position: @value', [
      '@value' => ucfirst($settings['position']),
    ]);
  }
  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 (!empty($settings['text_only'])) {
    $summary[] = t('Text only');
  }
  else {
    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;
}