public function DateRangeDurationWidget::settingsSummary in Datetime Extras 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/ DateRangeDurationWidget.php, line 148
Class
- DateRangeDurationWidget
- Plugin implementation of the 'daterange_duration' widget.
Namespace
Drupal\datetime_extras\Plugin\Field\FieldWidgetCode
public function settingsSummary() {
$default_duration_interval = $this
->getDefaultDurationInterval();
$duration_granularity = $this
->getSetting('duration_granularity');
$time_increment = $this
->getSetting('time_increment');
$increment_options = $this
->getTimeIncrementOptions();
$summary = [];
// Annoyingly, GranularityService::getHumanReadableStringFromDateInterval()
// expects the granularity as an array, but everything else stores/expects
// it as a string. So, we have to invoke the granularity service to convert
// the string into the granularity array.
$granularity_array = $this->granularityService
->convertGranularityStringToGranularityArray($duration_granularity);
$default_duration = $this->durationService
->getHumanReadableStringFromDateInterval($default_duration_interval, $granularity_array, ' ', 'short');
$summary['default_duration'] = $this
->t('Default duration: @duration', [
'@duration' => $default_duration,
]);
$summary['duration_granularity'] = $this
->t('Duration granularity: @granularity', [
'@granularity' => $duration_granularity,
]);
$summary['time_increment'] = $this
->t('Time increment : @increment', [
'@increment' => $increment_options[$time_increment],
]);
return $summary;
}