You are here

private function Presentation::buildHeader in Filebrowser 8.2

Same name and namespace in other branches
  1. 3.x src/Presentation.php \Drupal\filebrowser\Presentation::buildHeader()
1 call to Presentation::buildHeader()
Presentation::listView in src/Presentation.php

File

src/Presentation.php, line 374

Class

Presentation

Namespace

Drupal\filebrowser

Code

private function buildHeader(&$header, &$unsorted_rows, $visible_columns, $column_names, $default_sort, $sort_order) {

  /**
   * @var \Drupal\Core\StringTranslation\TranslatableMarkup  $specs
   */
  foreach ($column_names as $column_name => $column_spec) {
    if (isset($visible_columns[$column_name]) && $visible_columns[$column_name]) {
      if ($column_name == Common::ICON) {
        $header[$column_name] = [];
      }
      else {
        if (!empty($column_spec['sortable'])) {
          $header[$column_name] = [
            'data' => $column_spec['title'],
            'field' => $column_name,
          ];
        }
        else {
          $header[$column_name] = $column_spec['title'];
        }
      }
    }
    else {

      // If unused data then clean up !
      if ($unsorted_rows) {
        foreach ($unsorted_rows as &$row) {
          unset($row[$column_name]);
        }
      }
    }
  }
  $header[$default_sort]['sort'] = $sort_order;
}