public function ColorFieldFormatterSwatch::settingsSummary in Color Field 8.2
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/ ColorFieldFormatterSwatch.php, line 112
Class
- ColorFieldFormatterSwatch
- Plugin implementation of the color_field swatch formatter.
Namespace
Drupal\color_field\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$opacity = $this
->getFieldSetting('opacity');
$settings = $this
->getSettings();
$summary = [];
$summary[] = $this
->t('@shape', [
'@shape' => $this
->getShape($settings['shape']),
]);
$summary[] = $this
->t('Width: @width Height: @height', [
'@width' => $settings['width'],
'@height' => $settings['height'],
]);
if ($opacity && $settings['opacity']) {
$summary[] = $this
->t('Display with opacity.');
}
if ($settings['data_attribute']) {
$summary[] = $this
->t('Use HTML5 data attribute.');
}
return $summary;
}