public function DateRecurBasicFormatter::settingsSummary in Recurring Dates Field 8.2
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldFormatter/DateRecurBasicFormatter.php \Drupal\date_recur\Plugin\Field\FieldFormatter\DateRecurBasicFormatter::settingsSummary()
- 3.0.x src/Plugin/Field/FieldFormatter/DateRecurBasicFormatter.php \Drupal\date_recur\Plugin\Field\FieldFormatter\DateRecurBasicFormatter::settingsSummary()
- 3.1.x src/Plugin/Field/FieldFormatter/DateRecurBasicFormatter.php \Drupal\date_recur\Plugin\Field\FieldFormatter\DateRecurBasicFormatter::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 DateRangeDefaultFormatter::settingsSummary
File
- src/Plugin/ Field/ FieldFormatter/ DateRecurBasicFormatter.php, line 266 
Class
- DateRecurBasicFormatter
- Basic recurring date formatter.
Namespace
Drupal\date_recur\Plugin\Field\FieldFormatterCode
public function settingsSummary() : array {
  $this->formatType = $this
    ->getSetting('format_type');
  $summary = parent::settingsSummary();
  $countPerItem = $this
    ->getSetting('count_per_item');
  $showOccurrencesCount = $this
    ->getSetting('show_next');
  if ($showOccurrencesCount > 0) {
    $summary[] = $this
      ->formatPlural($showOccurrencesCount, 'Show maximum of @count occurrence @per', 'Show maximum of @count occurrences @per', [
      '@per' => $countPerItem ? $this
        ->t('per field item') : $this
        ->t('across all field items'),
    ]);
  }
  $start = new DrupalDateTime('today 9am');
  $endSameDay = clone $start;
  $endSameDay
    ->setTime(17, 0, 0);
  $summary['sample_same_day'] = [
    '#type' => 'inline_template',
    '#template' => '{{ label }}: {{ sample }}',
    '#context' => [
      'label' => $this
        ->t('Same day range'),
      'sample' => $this
        ->buildDateRangeValue($start, $endSameDay, TRUE),
    ],
  ];
  $endDifferentDay = clone $endSameDay;
  $endDifferentDay
    ->modify('+1 day');
  $summary['sample_different_day'] = [
    '#type' => 'inline_template',
    '#template' => '{{ label }}: {{ sample }}',
    '#context' => [
      'label' => $this
        ->t('Different day range'),
      'sample' => $this
        ->buildDateRangeValue($start, $endDifferentDay, TRUE),
    ],
  ];
  return $summary;
}