You are here

public function SingleDateTimeBase::settingsSummary in Single DateTimePicker 8

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 WidgetBase::settingsSummary

File

src/Plugin/Field/FieldWidget/SingleDateTimeBase.php, line 215

Class

SingleDateTimeBase
Base class for SingleDateTime widget types.

Namespace

Drupal\single_datetime\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $summary[] = $this
    ->t('Hours Format: @hour_format', [
    '@hour_format' => $this
      ->getSetting('hour_format'),
  ]);
  $summary[] = $this
    ->t('Set Seconds default 00: @allow_seconds', [
    '@allow_seconds' => !empty($this
      ->getSetting('allow_seconds')) ? $this
      ->t('Yes') : $this
      ->t('No'),
  ]);
  $summary[] = $this
    ->t('Minutes Granularity: @allow_times', [
    '@allow_times' => $this
      ->getSetting('allow_times'),
  ]);
  $summary[] = $this
    ->t('Allowed hours: @allowed_hours', [
    '@allowed_hours' => !empty($this
      ->getSetting('allowed_hours')) ? $this
      ->getSetting('allowed_hours') : $this
      ->t('All hours are allowed'),
  ]);
  $options = [
    '1' => $this
      ->t('Monday'),
    '2' => $this
      ->t('Tuesday'),
    '3' => $this
      ->t('Wednesday'),
    '4' => $this
      ->t('Thursday'),
    '5' => $this
      ->t('Friday'),
    '6' => $this
      ->t('Saturday'),
    '7' => $this
      ->t('Sunday'),
  ];
  $disabled_days = [];
  foreach ($this
    ->getSetting('disable_days') as $value) {
    if (!empty($value)) {
      $disabled_days[] = $options[$value];
    }
  }
  $disabled_days = implode(',', $disabled_days);
  $start_date = $this
    ->getSetting('start_date');
  $min_date = $this
    ->getSetting('min_date');
  $max_date = $this
    ->getSetting('max_date');
  $year_start = $this
    ->getSetting('year_start');
  $year_end = $this
    ->getSetting('year_end');
  $summary[] = $this
    ->t('Disabled days: @disabled_days', [
    '@disabled_days' => !empty($disabled_days) ? $disabled_days : $this
      ->t('None'),
  ]);
  $summary[] = $this
    ->t('Disabled dates: @disabled_dates', [
    '@disabled_dates' => !empty($this
      ->getSetting('exclude_date')) ? $this
      ->getSetting('exclude_date') : $this
      ->t('None'),
  ]);
  $summary[] = $this
    ->t('Display inline widget: @render_widget', [
    '@render_widget' => !empty($this
      ->getSetting('inline')) ? $this
      ->t('Yes') : $this
      ->t('No'),
  ]);
  $summary[] = $this
    ->t('Use mask: @mask', [
    '@mask' => !empty($this
      ->getSetting('mask')) ? $this
      ->t('Yes') : $this
      ->t('No'),
  ]);
  $summary[] = $this
    ->t('Theme: @theme', [
    '@theme' => ucfirst($this
      ->getSetting('datetimepicker_theme')),
  ]);
  $summary[] = $this
    ->t('Start date: @start_date', [
    '@start_date' => !empty($start_date) ? $start_date : $this
      ->t('Today'),
  ]);
  $summary[] = $this
    ->t('Minimum date/time: @min_date', [
    '@min_date' => !empty($min_date) ? $min_date : $this
      ->t('None'),
  ]);
  $summary[] = $this
    ->t('Maximum date/time: @max_date', [
    '@max_date' => !empty($max_date) ? $max_date : $this
      ->t('None'),
  ]);
  $summary[] = $this
    ->t('Start year: @year_start', [
    '@year_start' => !empty($year_start) ? $year_start : $this
      ->t('None'),
  ]);
  $summary[] = $this
    ->t('End year: @year_end', [
    '@year_end' => !empty($year_end) ? $year_end : $this
      ->t('None'),
  ]);
  $summary[] = $this
    ->t('Allow blank: @allow_blank', [
    '@allow_blank' => !empty($this
      ->getSetting('allow_blank')) ? $this
      ->t('Yes') : $this
      ->t('No'),
  ]);
  return $summary;
}