1.20.x cache.inc _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE)

Fetch the plugin data from cache.

File

modules/views/includes/cache.inc, line 127
Load Views' data so that it knows what is available to build queries from.

Code

function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) {
  static $cache = NULL;
  if (!isset($cache) || $reset) {
    // Load necessary code once.
    views_include_handlers();

    // Because plugin data contains translated strings, and as such can be
    // expensive to build, the results are cached per language.
    global $language;
    $cache_key = 'views_plugin_data:' . $language->langcode;
    if ($reset) {
      $cache = NULL;
    }
    else {
      if ($cache_object = cache_get($cache_key, 'views')) {
        $cache = $cache_object->data;
      }
    }

    // If not available in the cache, build it and cache it.
    if (!$cache) {
      $cache = views_discover_plugins();
      cache_set($cache_key, $cache, 'views');
    }
  }

  if (!$type && !$plugin) {
    return $cache;
  }
  elseif (!$plugin) {
    // Not in the if above so the else below won't run
    if (isset($cache[$type])) {
      return $cache[$type];
    }
  }
  elseif (isset($cache[$type][$plugin])) {
    return $cache[$type][$plugin];
  }

  // Return an empty array if there is no match.
  return array();
}