trait DateTimeDayTrait in Date time day 8
Provides friendly methods for date_time_day.
Hierarchy
- trait \Drupal\date_time_day\DateTimeDayTrait
1 file declares its use of DateTimeDayTrait
- DateTimeDayDefaultFormatter.php in src/
Plugin/ Field/ FieldFormatter/ DateTimeDayDefaultFormatter.php
File
- src/
DateTimeDayTrait.php, line 10
Namespace
Drupal\date_time_dayView source
trait DateTimeDayTrait {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
$day_separator = $this
->getSetting('day_separator');
$time_separator = $this
->getSetting('time_separator');
foreach ($items as $delta => $item) {
$elements[$delta]['date'] = $this
->buildDateWithIsoAttribute($item->date);
if (!empty($item->start_time)) {
$elements[$delta]['day_separator'] = [
'#plain_text' => $day_separator,
];
$elements[$delta]['start_time'] = $this
->buildTimeWithAttribute($item->start_time);
if (!empty($item->end_time)) {
$elements[$delta]['time_separator'] = [
'#plain_text' => $time_separator,
];
$elements[$delta]['end_time'] = $this
->buildTimeWithAttribute($item->end_time);
}
}
}
return $elements;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateTimeDayTrait:: |
public | function |