You are here

public function SmartDateTimezoneWidget::settingsSummary in Smart Date 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateTimezoneWidget::settingsSummary()
  2. 3.x src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateTimezoneWidget::settingsSummary()
  3. 3.1.x src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateTimezoneWidget::settingsSummary()
  4. 3.2.x src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateTimezoneWidget::settingsSummary()
  5. 3.3.x src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateTimezoneWidget::settingsSummary()
  6. 3.4.x src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateTimezoneWidget::settingsSummary()

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides SmartDateDefaultWidget::settingsSummary

File

src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php, line 130

Class

SmartDateTimezoneWidget
Plugin implementation of the 'smartdate_timezone' widget.

Namespace

Drupal\smart_date\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  switch ($this
    ->getSetting('default_tz')) {
    case '':
      $summary[] = $this
        ->t("The site's timezone will be used unless overridden");
      break;
    case 'user':
      $summary[] = $this
        ->t("The user's timezone will be used by default");
      break;
    case 'custom':
      $summary[] = $this
        ->t('Custom default timezone: @custom_tz', [
        '@custom_tz' => $this
          ->getSetting('custom_tz'),
      ]);
      break;
  }
  if ($allowed_tz = $this
    ->getSetting('allowed_timezones')) {
    $summary[] = $this
      ->t('Allowed timezones: @timezones', [
      '@timezones' => implode(', ', $allowed_tz),
    ]);
  }
  return $summary;
}