You are here

public function StoreDateTimeFormatter::settingsSummary in Commerce Core 8.2

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

modules/store/src/Plugin/Field/FieldFormatter/StoreDateTimeFormatter.php, line 133

Class

StoreDateTimeFormatter
Plugin implementation of the 'commerce_store_datetime' formatter.

Namespace

Drupal\commerce_store\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $date_format = $this
    ->getDateFormat();
  $date = new DrupalDateTime('now', $this
    ->getTimezone());

  // Uses the same summary format as DateTimeDefaultFormatter.
  $summary[] = $this
    ->t('Format: @date_format', [
    '@date_format' => $date
      ->format($date_format
      ->getPattern()),
  ]);
  return $summary;
}