public function TextWithTitleTabsHorizontalFormatter::view in Text with Title Field 8
Overide the view method so we can wrap the result in the accordion markup.
Overrides FormatterBase::view
File
- src/
Plugin/ Field/ FieldFormatter/ TextWithTitleTabsHorizontalFormatter.php, line 26
Class
- TextWithTitleTabsHorizontalFormatter
- Implementation of the 'TextWithTitleTabsHorizontalFormatter' formatter.
Namespace
Drupal\text_with_title\Plugin\Field\FieldFormatterCode
public function view(FieldItemListInterface $items, $langcode = NULL) {
// Default the language to the current content language.
if (empty($langcode)) {
$langcode = \Drupal::languageManager()
->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
->getId();
}
$elements = $this
->viewElements($items, $langcode);
$build = [
'#theme' => 'text_with_title_tabs_horizontal',
'#tabs' => $elements,
];
return $build;
}