protected function OfficeHoursFormatterBase::addStatusFormatter in Office Hours 8
Add a 'status' formatter before or after the hours, if necessary.
Parameters
\Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemListInterface $items:
$langcode:
array $elements:
Return value
array
2 calls to OfficeHoursFormatterBase::addStatusFormatter()
- OfficeHoursFormatterDefault::viewElements in src/
Plugin/ Field/ FieldFormatter/ OfficeHoursFormatterDefault.php - Builds a renderable array for a field value.
- OfficeHoursFormatterTable::viewElements in src/
Plugin/ Field/ FieldFormatter/ OfficeHoursFormatterTable.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ OfficeHoursFormatterBase.php, line 323
Class
- OfficeHoursFormatterBase
- Abstract plugin implementation of the formatter.
Namespace
Drupal\office_hours\Plugin\Field\FieldFormatterCode
protected function addStatusFormatter(OfficeHoursItemListInterface $items, $langcode, array $elements) {
if (!empty($this->settings['current_status']['position'])) {
$formatter = new OfficeHoursFormatterStatus($this->pluginId, $this->pluginDefinition, $this->fieldDefinition, $this->settings, $this->viewMode, $this->label, $this->thirdPartySettings);
$new_element = $formatter
->viewElements($items, $langcode);
switch ($new_element['#position']) {
case 'before':
array_unshift($elements, $new_element);
break;
case 'after':
array_push($elements, $new_element);
break;
default:
break;
}
}
return $elements;
}