private function SmartDateRecurTrait::formatWithinDay in Smart Date 3.3.x
Same name and namespace in other branches
- 3.1.x modules/smart_date_recur/src/SmartDateRecurTrait.php \Drupal\smart_date_recur\SmartDateRecurTrait::formatWithinDay()
- 3.2.x modules/smart_date_recur/src/SmartDateRecurTrait.php \Drupal\smart_date_recur\SmartDateRecurTrait::formatWithinDay()
- 3.4.x modules/smart_date_recur/src/SmartDateRecurTrait.php \Drupal\smart_date_recur\SmartDateRecurTrait::formatWithinDay()
Helper function to create a collapsed display of events within a day.
2 calls to SmartDateRecurTrait::formatWithinDay()
- SmartDateDailyRangeFormatter::viewElements in modules/
smart_date_recur/ src/ Plugin/ Field/ FieldFormatter/ SmartDateDailyRangeFormatter.php - SmartDateRecurrenceFormatter::viewElements in modules/
smart_date_recur/ src/ Plugin/ Field/ FieldFormatter/ SmartDateRecurrenceFormatter.php
File
- modules/
smart_date_recur/ src/ SmartDateRecurTrait.php, line 31
Class
- SmartDateRecurTrait
- Provides friendly methods for smart date range.
Namespace
Drupal\smart_date_recurCode
private function formatWithinDay(array $instances, array $settings) {
$settings_notime = $this
->settingsFormatNoTime($settings);
$settings_nodate = $this
->settingsFormatNoDate($settings);
$settings_notz = $this
->settingsFormatNoTz($settings_nodate);
$output = [];
foreach ($instances as $time_set) {
$this_output = [];
$time_output = [];
$last_time = array_pop($time_set);
foreach ($time_set as $key => $instance) {
$time_output[$key] = static::formatSmartDate($instance->value, $instance->end_value, $settings_notz, $instance->timezone);
$time_output[$key]['#suffix'] = ', ';
}
$time_output[] = static::formatSmartDate($last_time->value, $last_time->end_value, $settings_nodate, $last_time->timezone);
$this_output['time'] = $time_output;
$this_output['join'] = [
'#markup' => $settings['join'],
];
$this_output['date']['#markup'] = static::formatSmartDate($last_time->value, $last_time->value, $settings_notime, $last_time->timezone, 'string');
$this_output['#attributes']['class'] = [
'smart-date--daily-times',
];
$this_output['#type'] = 'container';
$output[] = $this
->massageForOutput($this_output, $settings);
}
return $output;
}