You are here

public function ParagraphsTableFormatter::settingsSummary in Paragraphs table 8

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/ParagraphsTableFormatter.php, line 227

Class

ParagraphsTableFormatter
Plugin implementation of the 'paragraphs_table_formatter' formatter.

Namespace

Drupal\paragraphs_table\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];

  // Implement settings summary.
  $view_modes = $this->entityDisplayRepository
    ->getViewModeOptions($this
    ->getFieldSetting('target_type'));
  $view_mode = $this
    ->getSetting('view_mode');
  $summary[] = $this
    ->t('Rendered as @view_mode', [
    '@view_mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode,
  ]);
  if (!empty($this
    ->getSetting('caption'))) {
    $summary[] = $this
      ->t('Caption: @caption', [
      '@caption' => $this
        ->getSetting('caption'),
    ]);
  }
  if (!empty($this
    ->getSetting('vertical'))) {
    $summary[] = $this
      ->t('Table mode vertical');
  }
  if (!empty($this
    ->getSetting('mode'))) {
    $summary[] = $this
      ->t('Mode: @mode', [
      '@mode' => $this
        ->getSetting('mode'),
    ]);
  }
  if (!empty($this
    ->getSetting('chart_type'))) {
    $summary[] = $this
      ->t('Chart type: @type', [
      '@type' => $this
        ->getSetting('chart_type'),
    ]);
  }
  if (!empty($this
    ->getSetting('import'))) {
    $summary[] = $this
      ->t('Label import csv: @import', [
      '@import' => $this
        ->getSetting('import'),
    ]);
  }
  if (!empty($this
    ->getSetting('empty_cell_value'))) {
    $summary[] = $this
      ->t('Replace empty cells with: @replace', [
      '@replace' => $this
        ->getSetting('empty_cell_value'),
    ]);
  }
  if (!empty($this
    ->getSetting('empty'))) {
    $summary[] = $this
      ->t('Hide empty columns');
  }
  if (!empty($this
    ->getSetting('ajax'))) {
    $summary[] = $this
      ->t('Load ajax');
  }
  if (!empty($this
    ->getSetting('custom_class'))) {
    $summary[] = $this
      ->t('Custom class: @class', [
      '@class' => $this
        ->getSetting('custom_class'),
    ]);
  }
  if (!empty($this
    ->getSetting('hide_line_operations'))) {
    $summary[] = $this
      ->t('Hide line operations.');
  }
  return $summary;
}