You are here

public function EntityReferenceTableFormatter::settingsSummary in Reference Table Formatter 2.0.x

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/EntityReferenceTableFormatter.php, line 149

Class

EntityReferenceTableFormatter
A field formatter to display a table.

Namespace

Drupal\reference_table_formatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $settings = $this
    ->getSettings();
  $view_modes = $this
    ->getConfigurableViewModes();
  $view_mode = $settings['view_mode'];
  $arguments = [
    '@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode,
  ];
  $summary[] = $this
    ->t('Showing a table of rendered @mode entity fields', $arguments);
  if ($settings['show_entity_label']) {
    $summary[] = $this
      ->t('Entity label displayed');
  }
  if ($settings['hide_header']) {
    $summary[] = $this
      ->t('Table header hidden');
  }
  if ($settings['empty_cell_value']) {
    $summary[] = $this
      ->t('Empty cell value: @value', [
      '@value' => $settings['empty_cell_value'],
    ]);
  }
  return $summary;
}