function PreprocessHooks::preprocessViewsViewTable

Same name and namespace in other branches
  1. 11.x core/themes/default_admin/src/Hook/PreprocessHooks.php \Drupal\default_admin\Hook\PreprocessHooks::preprocessViewsViewTable()

Implements hook_preprocess_HOOK() for views_view_table.

@todo Revisit after https://www.drupal.org/node/3025726 or https://www.drupal.org/node/1973418 is in.

Attributes

#[Hook('preprocess_views_view_table')]

File

core/themes/default_admin/src/Hook/PreprocessHooks.php, line 1413

Class

PreprocessHooks
Provides preprocess implementations.

Namespace

Drupal\default_admin\Hook

Code

public function preprocessViewsViewTable(array &$variables) : void {
  if (!empty($variables['header'])) {
    foreach ($variables['header'] as &$header_cell) {
      if (!empty($header_cell['url'])) {
        $parsed_url = UrlHelper::parse($header_cell['url']);
        $query = !empty($parsed_url['query']) ? $parsed_url['query'] : [];
        if (isset($query['order'], $query['sort'])) {
          $header_cell['attributes']->addClass('sortable-heading');
        }
      }
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.