protected function IntervalFormatterBase::formatInterval in Interval Field 8
Formats an interval as a string.
Parameters
\Drupal\interval\IntervalItemInterface $item: Interval item to format.
Return value
string Formatted interval.
2 calls to IntervalFormatterBase::formatInterval()
- IntervalFormatterBase::viewElements in src/
Plugin/ Field/ FieldFormatter/ IntervalFormatterBase.php - Builds a renderable array for a field value.
- IntervalFormatterRaw::viewElements in src/
Plugin/ Field/ FieldFormatter/ IntervalFormatterRaw.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ IntervalFormatterBase.php, line 23
Class
- IntervalFormatterBase
- Provides a base formatter class for interval field formatters.
Namespace
Drupal\interval\Plugin\Field\FieldFormatterCode
protected function formatInterval(IntervalItemInterface $item) {
$interval = $item
->getIntervalPlugin();
return $this
->formatPlural($item
->getInterval(), '1 @singular', '@count @plural', [
'@singular' => $interval['singular'],
'@plural' => $interval['plural'],
]);
}