You are here

public function PriceDefaultFormatter::settingsSummary in Price 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::settingsSummary()
  2. 3.x src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::settingsSummary()
  3. 2.x src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::settingsSummary()
  4. 3.0.x src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::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

src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php, line 113

Class

PriceDefaultFormatter
Plugin implementation of the 'price_default' formatter.

Namespace

Drupal\price\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  if ($this
    ->getSetting('strip_trailing_zeroes')) {
    $summary[] = $this
      ->t('Strip trailing zeroes after the decimal point.');
  }
  else {
    $summary[] = $this
      ->t('Do not strip trailing zeroes after the decimal point.');
  }
  $currency_display = $this
    ->getSetting('currency_display');
  $currency_display_options = [
    'symbol' => $this
      ->t('Symbol (e.g. "$")'),
    'code' => $this
      ->t('Currency code (e.g. "USD")'),
    'none' => $this
      ->t('None'),
  ];
  $summary[] = $this
    ->t('Currency display: @currency_display.', [
    '@currency_display' => $currency_display_options[$currency_display],
  ]);
  return $summary;
}