You are here

protected function FieldGroupTable::buildAdditionalContent in Field Group Table 8

Build header content (before table).

Parameters

string $type: Type of additional content.

Return value

array Table header content.

1 call to FieldGroupTable::buildAdditionalContent()
FieldGroupTable::preRender in src/Plugin/field_group/FieldGroupFormatter/FieldGroupTable.php

File

src/Plugin/field_group/FieldGroupFormatter/FieldGroupTable.php, line 566

Class

FieldGroupTable
Plugin implementation of the 'field_group_table' formatter.

Namespace

Drupal\field_group_table\Plugin\field_group\FieldGroupFormatter

Code

protected function buildAdditionalContent($type) {
  $build = [
    '#type' => 'container',
  ];
  switch ($type) {
    case self::ADD_CONTENT_HEADER:
      $build['#attributes']['class'][] = 'table-header';
      $visibility = self::DISPLAY_ABOVE;
      break;
    case self::ADD_CONTENT_FOOTER:
      $build['#attributes']['class'][] = 'table-footer';
      $visibility = self::DISPLAY_BELOW;
      break;
    default:
      $visibility = self::DISPLAY_HIDDEN;
      break;
  }
  if ($this
    ->getSetting('label_visibility') == $visibility) {
    $build['label'] = [
      '#type' => 'label',
      '#title' => $this->group->label,
      '#title_display' => 'above',
      '#attributes' => [
        'class' => 'table-label',
      ],
    ];
  }
  if ($this
    ->getSetting('desc_visibility') == $visibility && $this
    ->getSetting('desc')) {
    $build['desc'] = [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#value' => Xss::filter($this
        ->getSetting('desc')),
      '#attributes' => [
        'class' => [
          'table-desc',
        ],
      ],
    ];
  }
  return count($build) > 2 ? $build : [];
}