You are here

public function TextWithTitleTabsVerticalFormatter::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/TextWithTitleTabsVerticalFormatter.php, line 65

Class

TextWithTitleTabsVerticalFormatter
Plugin implementation of the 'TextWithTitleTabsVerticalFormatter' formatter.

Namespace

Drupal\text_with_title\Plugin\Field\FieldFormatter

Code

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_vertical',
    '#tabs' => $elements,
    '#tabs_width' => $this
      ->getSetting('tabs_width'),
  ];
  return $build;
}