You are here

public function PlainStringFormatter::settingsSummary in String field formatter 8

Same name and namespace in other branches
  1. 8.x src/Plugin/Field/FieldFormatter/PlainStringFormatter.php \Drupal\string_field_formatter\Plugin\Field\FieldFormatter\PlainStringFormatter::settingsSummary()
  2. 2.0.x src/Plugin/Field/FieldFormatter/PlainStringFormatter.php \Drupal\string_field_formatter\Plugin\Field\FieldFormatter\PlainStringFormatter::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

src/Plugin/Field/FieldFormatter/PlainStringFormatter.php, line 82

Class

PlainStringFormatter
Plugin implementation of the 'plain_string_formatter' formatter.

Namespace

Drupal\string_field_formatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = array();
  $wrap_tag = $this
    ->getSetting('wrap_tag');
  if ('_none' == $wrap_tag) {
    $summary[] = t('No wrap tag defined.');
  }
  else {
    $summary[] = t('Wrap text with tag: @tag', array(
      '@tag' => $wrap_tag,
    ));
  }
  $class = $this
    ->getSetting('wrap_class');
  $class = $this
    ->prepareClasses($class);
  if ($class) {
    $summary[] = $this
      ->formatPlural(count($class), t('Wrapper additional CSS class: @class.', array(
      '@class' => implode('', $class),
    )), t('Wrapper additional CSS classes: @class.', array(
      '@class' => implode(' ', $class),
    )));
  }
  else {
    $summary[] = t('No additional CSS class defined.');
  }
  return $summary;
}