You are here

public function ColorFieldWidgetBox::settingsSummary in Color Field 8.2

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides WidgetBase::settingsSummary

File

src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php, line 79

Class

ColorFieldWidgetBox
Plugin implementation of the color_field box widget.

Namespace

Drupal\color_field\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $default_colors = $this
    ->getSetting('default_colors');
  if (!empty($default_colors)) {
    preg_match_all("/#[0-9A-F]{6}/i", $default_colors, $default_colors, PREG_SET_ORDER);
    foreach ($default_colors as $color) {
      $colors = $color[0];
      $summary[] = $colors;
    }
  }
  if (empty($summary)) {
    $summary[] = $this
      ->t('No default colors');
  }
  return $summary;
}