You are here

public function BooleanFormatter::settingsSummary in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\BooleanFormatter::settingsSummary()

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

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php, line 115

Class

BooleanFormatter
Plugin implementation of the 'boolean' formatter.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $setting = $this
    ->getSetting('format');
  if ($setting == 'custom') {
    $summary[] = $this
      ->t('Custom text: @true_label / @false_label', [
      '@true_label' => $this
        ->getSetting('format_custom_true'),
      '@false_label' => $this
        ->getSetting('format_custom_false'),
    ]);
  }
  else {
    $formats = $this
      ->getOutputFormats();
    $summary[] = $this
      ->t('Display: @true_label / @false_label', [
      '@true_label' => $formats[$setting][0],
      '@false_label' => $formats[$setting][1],
    ]);
  }
  return $summary;
}