function LinkFormatter::settingsSummary

Same name in other branches
  1. 8.9.x core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::settingsSummary()
  2. 10 core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::settingsSummary()
  3. 11.x core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::settingsSummary()

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.