You are here

function _quant_get_data in Quant 7

Fetch quant data

Parameters

$hook: The hook used to populate the desired data. This is also used as the cache key and alter hook.

$reset: TRUE if the data should be completely refetched from the hooks. Defaults to FALSE.

Return value

The requested data

2 calls to _quant_get_data()
quant_get_quants in ./quant.module
Fetch all available quants
quant_get_quant_charts in ./quant.module
Fetch all available charts

File

./quant.module, line 165

Code

function _quant_get_data($hook, $reset = FALSE) {
  static $data = array();

  // Act if the static cache is not yet populated
  if (!isset($data[$hook]) || $reset) {

    // Check the cache table next
    $cache = !$reset ? cache_get($hook) : NULL;

    // See if the cache has data
    if (isset($cache->data)) {

      // Use the cached tree
      $data[$hook] = $cache->data;
    }
    else {

      // Invoke the hooks
      $data[$hook] = module_invoke_all($hook);

      // Allow modules to alter the quants
      drupal_alter($hook, $data[$hook]);

      // Cache the quants
      cache_set($hook, $data[$hook], 'cache', CACHE_TEMPORARY);
    }
  }
  return $data[$hook];
}