You are here

public function ApStyleDateFieldFormatter::settingsSummary in AP Style Date 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/ApStyleDateFieldFormatter.php, line 204

Class

ApStyleDateFieldFormatter
Plugin implementation of the 'timestamp' formatter as time ago.

Namespace

Drupal\date_ap_style\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  if ($this
    ->getSetting('always_display_year')) {
    $summary[] = $this
      ->t('Always displaying year');
  }
  if ($this
    ->getSetting('display_day')) {
    $summary[] = $this
      ->t('Displaying day of the week');
  }
  if ($this
    ->getSetting('use_today')) {
    $today = '';
    if ($this
      ->getSetting('cap_today')) {
      $today = ' (capitalized)';
    }
    $summary[] = $this
      ->t('Displaying today@today', [
      '@today' => $today,
    ]);
  }
  if ($this
    ->getSetting('display_time')) {
    $display_time = $this
      ->t('Displaying time');
    if ($this
      ->getSetting('time_before_date')) {
      $display_time .= ' (before date)';
    }
    else {
      $display_time .= ' (after date)';
    }
    $summary[] = $display_time;
    if ($this
      ->getSetting('use_all_day')) {
      $summary[] = 'Show "All Day" instead of midnight';
    }
    elseif ($this
      ->getSetting('display_noon_and_midnight')) {
      $noon_and_midnight = '';
      if ($this
        ->getSetting('capitalize_noon_and_midnight')) {
        $noon_and_midnight = ' (capitalized)';
      }
      $summary[] = $this
        ->t('Displaying noon and midnight@noon_and_midnight', [
        '@noon_and_midnight' => $noon_and_midnight,
      ]);
    }
  }
  if ($timezone = $this
    ->getSetting('timezone')) {
    $summary[] = $this
      ->t('Time zone: @timezone', [
      '@timezone' => $timezone,
    ]);
  }
  return $summary;
}