Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ViewsData.php

function ViewsData::fetchBaseTables

Fetches a list of all base tables available.

Return value

array An array of base table data keyed by table name. Each item contains the following keys:

  • title: The title label for the base table.
  • help: The help text for the base table.
  • weight: The weight of the base table.

File

core/modules/views/src/ViewsData.php, line 273

Class

ViewsData
Class to manage and lazy load cached views data.

Namespace

Drupal\views

Code

public function fetchBaseTables() {
    $tables = [];
    foreach ($this->getAll() as $table => $info) {
        if (!empty($info['table']['base'])) {
            $tables[$table] = [
                'title' => $info['table']['base']['title'],
                'help' => !empty($info['table']['base']['help']) ? $info['table']['base']['help'] : '',
                'weight' => !empty($info['table']['base']['weight']) ? $info['table']['base']['weight'] : 0,
            ];
        }
    }
    // Sorts by the 'weight' and then by 'title' element.
    uasort($tables, function ($a, $b) {
        if ($a['weight'] != $b['weight']) {
            return $a['weight'] <=> $b['weight'];
        }
        return $a['title'] <=> $b['title'];
    });
    return $tables;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal