protected function TimeRangePickerFormatter::viewValue in Time Field Picker 8.5
Generate the output appropriate for one field item.
Parameters
\Drupal\Core\Field\FieldItemInterface $item: One field item.
Return value
string The textual output generated.
1 call to TimeRangePickerFormatter::viewValue()
- TimeRangePickerFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ TimeRangePickerFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ TimeRangePickerFormatter.php, line 32
Class
- TimeRangePickerFormatter
- Plugin implementation of the 'time_range_picker_formatter' formatter.
Namespace
Drupal\time_picker\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
$time_format = '';
if (!empty($item->start)) {
$time_format = $item->start;
}
if (!empty($item->end)) {
$time_format = !empty($item->start) ? $item->start . ' - ' . $item->end : $item->end;
}
return $time_format;
}