You are here

public function AddtocalView::settingsSummary in Add to Cal 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/AddtocalView.php \Drupal\addtocal\Plugin\Field\FieldFormatter\AddtocalView::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 DateTimeCustomFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/AddtocalView.php, line 72

Class

AddtocalView
Add to Cal view formatter.

Namespace

Drupal\addtocal\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $field = $this->fieldDefinition;

  // Date Range field type settings.
  if ($field
    ->getType() == 'daterange' || $field
    ->getType() == 'date_recur') {
    $summary[] = $this
      ->t('Separator: %separator', [
      '%separator' => $this
        ->getSetting('separator'),
    ]);
  }
  $title = $this
    ->getSetting('event_title');
  $summary[] = $this
    ->t('Event title: %title', [
    '%title' => $title ?: $this
      ->t('Entity label'),
  ]);
  $location = $this
    ->getSetting('location');
  if ($location) {
    $summary[] = $this
      ->t('Event location: %location', [
      '%location' => $location,
    ]);
  }
  $description = $this
    ->getSetting('description');
  if ($description) {
    $summary[] = $this
      ->t('Event description: %description', [
      '%description' => $description,
    ]);
  }
  $past_events = $this
    ->getSetting('past_events') ? 'Yes' : 'No';
  $summary[] = $this
    ->t('Show the widget for past events: %past_events', [
    '%past_events' => $past_events,
  ]);
  return $summary;
}