public function ViewsData::get

Gets data for a particular table, or all tables.

Parameters

string|null $key: The key of the cache entry to retrieve. Defaults to NULL, this will return all table data.

Return value

array $data An array of table data.

1 call to ViewsData::get()
ViewsData::fetchBaseTables in drupal/core/modules/views/lib/Drupal/views/ViewsData.php
Fetches a list of all base tables available.

File

drupal/core/modules/views/lib/Drupal/views/ViewsData.php, line 102
Contains \Drupal\views\ViewsData.

Class

ViewsData
Class to manage and lazy load cached views data.

Namespace

Drupal\views

Code

public function get($key = NULL) {
  if ($key) {
    if (!isset($this->storage[$key])) {

      // Prepare a cache ID.
      $cid = $this->baseCid . ':' . $key;
      $from_cache = FALSE;
      if ($data = $this
        ->cacheGet($cid)) {
        $this->storage[$key] = $data->data;
        $from_cache = TRUE;
      }
      elseif (!$this->fullyLoaded) {
        $this->storage = $this
          ->getData();
      }
      if (!$from_cache) {
        if (!isset($this->storage[$key])) {

          // Write an empty cache entry if no information for that table
          // exists to avoid repeated cache get calls for this table and
          // prevent loading all tables unnecessarily.
          $this->storage[$key] = array();
        }

        // Create a cache entry for the requested table.
        $this->cacheBackend
          ->set($this
          ->prepareCid($cid), $this->storage[$key]);
      }
    }
    if (isset($this->storage[$key])) {
      return $this->storage[$key];
    }

    // If the key is invalid, return an empty array.
    return array();
  }
  else {
    if (!$this->fullyLoaded) {
      $this->storage = $this
        ->getData();
    }
  }
  return $this->storage;
}