public function PlainStringFormatter::settingsSummary in String field formatter 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldFormatter/PlainStringFormatter.php \Drupal\string_field_formatter\Plugin\Field\FieldFormatter\PlainStringFormatter::settingsSummary()
- 8.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 StringFormatter::settingsSummary
File
- src/
Plugin/ Field/ FieldFormatter/ PlainStringFormatter.php, line 74
Class
- PlainStringFormatter
- Plugin implementation of the 'plain_string_formatter' formatter.
Namespace
Drupal\string_field_formatter\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$summary = parent::settingsSummary();
$wrapTags = $this
->wrapTagOptions();
$wrapTag = $this
->getSetting('wrap_tag');
$hasWrapTag = $wrapTag !== static::$wrapTagEmptyValue;
$wrapTagLabel = isset($wrapTags[$wrapTag]) ? $wrapTags[$wrapTag] : $wrapTag;
$summary[] = $hasWrapTag ? $this
->t('Wrapper tag: @tag', [
'@tag' => $wrapTagLabel,
]) : $this
->t('No wrapper tag defined.');
if ($hasWrapTag) {
$class = $this
->prepareClasses($this
->getSetting('wrap_class'));
$args = [
'@class' => implode(' ', $class),
];
$summary[] = $class ? $this
->formatPlural(count($class), 'Class: @class', 'Classes: @class', $args) : $this
->t('Without classes.');
}
return $summary;
}