You are here

public function ColorFieldWidgetGrid::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/ColorFieldWidgetGrid.php, line 90

Class

ColorFieldWidgetGrid
Plugin implementation of the 'color_field_default' widget.

Namespace

Drupal\color_field\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $cell_width = $this
    ->getSetting('cell_width');
  $cell_height = $this
    ->getSetting('cell_height');
  $cell_margin = $this
    ->getSetting('cell_margin');
  $box_width = $this
    ->getSetting('box_width');
  $box_height = $this
    ->getSetting('box_height');
  $columns = $this
    ->getSetting('columns');
  if (!empty($cell_width)) {
    $summary[] = $this
      ->t('Cell width: @cell_width', [
      '@cell_width' => $cell_width,
    ]);
  }
  if (!empty($cell_height)) {
    $summary[] = $this
      ->t('Cell height: @cell_height', [
      '@cell_height' => $cell_height,
    ]);
  }
  if (!empty($cell_margin)) {
    $summary[] = $this
      ->t('Cell margin: @cell_margin', [
      '@cell_margin' => $cell_margin,
    ]);
  }
  if (!empty($box_width)) {
    $summary[] = $this
      ->t('Box width: @box_width', [
      '@box_width' => $box_width,
    ]);
  }
  if (!empty($box_height)) {
    $summary[] = $this
      ->t('Box height: @box_height', [
      '@box_height' => $box_height,
    ]);
  }
  if (!empty($columns)) {
    $summary[] = $this
      ->t('Columns: @columns', [
      '@columns' => $columns,
    ]);
  }
  if (empty($summary)) {
    $summary[] = $this
      ->t('No placeholder');
  }
  return $summary;
}