Same name and namespace in other branches
  1. 8.x-2.x src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php \Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterSwatch::settingsSummary() 1 comment

File

src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php, line 80

Class

ColorFieldFormatterSwatch
Plugin implementation of the color_field swatch formatter.

Namespace

Drupal\color_field\Plugin\Field\FieldFormatter

Code

public function settingsSummary() : array {
    $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;
}