You are here

public function WrapperClassFormatter::settingsSummary in Element Class Formatter 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/WrapperClassFormatter.php, line 113

Class

WrapperClassFormatter
A field formatter for wrapping text with a class.

Namespace

Drupal\element_class_formatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $class = $this
    ->getSetting('class');
  if ($linked = $this
    ->getSetting('link')) {
    $summary[] = $this
      ->t('Link: @link', [
      '@link' => $linked ? 'yes' : 'no',
    ]);
    if ($linked_class = $this
      ->getSetting('link_class')) {
      $summary[] = $this
        ->t('Link class: @link_class', [
        '@link_class' => $linked_class,
      ]);
    }
  }
  if ($this
    ->getSetting('summary')) {
    $summary[] = $this
      ->t('Output: Summary if present, otherwise the value trimmed to %char characters', [
      '%char' => $this
        ->getSetting('trim'),
    ]);
  }
  if ($tag = $this
    ->getSetting('tag')) {
    $summary[] = $this
      ->t('Tag: @tag', [
      '@tag' => $tag,
    ]);
  }
  return $this
    ->elementClassSettingsSummary($summary, $class);
}