protected function RangeFormatterBase::viewElementSeparate in Range 8
Helper method. Returns the separate values renderable array.
Parameters
\Drupal\range\RangeItemInterface $item: Range field item.
string $from_value: Field FROM value.
string $to_value: Field TO value.
Return value
array Field value renderable array.
1 call to RangeFormatterBase::viewElementSeparate()
- RangeFormatterBase::viewElements in src/
Plugin/ Field/ FieldFormatter/ RangeFormatterBase.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ RangeFormatterBase.php, line 215
Class
- RangeFormatterBase
- Parent plugin for decimal and integer range formatters.
Namespace
Drupal\range\Plugin\Field\FieldFormatterCode
protected function viewElementSeparate(RangeItemInterface $item, $from_value, $to_value) {
$output = [
'#theme' => 'range_formatter_range_separate',
'#item' => $item,
'#from' => $from_value,
'#range_separator' => $this
->getSetting('range_separator'),
'#to' => $to_value,
];
if ($this
->getSetting('from_prefix_suffix')) {
$output['#from_prefix'] = FieldFilteredMarkup::create($this
->getFieldSetting('from')['prefix']);
$output['#from_suffix'] = FieldFilteredMarkup::create($this
->getFieldSetting('from')['suffix']);
}
if ($this
->getSetting('to_prefix_suffix')) {
$output['#to_prefix'] = FieldFilteredMarkup::create($this
->getFieldSetting('to')['prefix']);
$output['#to_suffix'] = FieldFilteredMarkup::create($this
->getFieldSetting('to')['suffix']);
}
return $output;
}