You are here

function radiactivity_get_incident_storage in Radioactivity 7

Enter description here ...

Parameters

unknown_type $field_id:

2 calls to radiactivity_get_incident_storage()
radioactivity_cron in ./radioactivity.module
Implementation of hook_cron
radioactivity_incident_emit in ./radioactivity.module
Emit the indicental energy of the field

File

./radioactivity.module, line 101

Code

function radiactivity_get_incident_storage($field_id) {
  static $cache = array();

  // for instances
  static $included = false;

  // for base class
  static $includes = array();

  // for other classes
  $field_info = field_info_field_by_id($field_id);
  $storage = $field_info['settings']['storage'];
  $key = $storage . '-' . $field_id;

  // make hookable
  // if cached?
  if (isset($cache[$key])) {
    return $cache[$key];
  }
  $class = "radioactivity_" . $storage . "_incident_storage";

  // main class included?
  if (!$included) {
    include "storage/radioactivity_incident_storage.php";
    $included = true;
  }

  // this storage class included?
  if (!isset($includes[$storage])) {
    include "storage/" . $class . ".php";
    $includes[$storage] = true;
  }

  // add to cache
  if (class_exists($class)) {
    $cache[$key] = new $class($field_id);
  }
  else {
    $cache[$key] = NULL;
  }
  return $cache[$key];
}