You are here

function cache_actions_rules_cache_get_id in Cache Actions 6.2

Same name and namespace in other branches
  1. 7.2 plugins/cache/rules.inc \cache_actions_rules_cache_get_id()
  2. 7 plugins/cache/rules.inc \cache_actions_rules_cache_get_id()

Figure out an id for our cache based upon input and settings.

2 calls to cache_actions_rules_cache_get_id()
cache_actions_rules_cache_get_cache in plugins/cache/rules.inc
Get cached content.
cache_actions_rules_cache_set_cache in plugins/cache/rules.inc
Set cached content.

File

plugins/cache/rules.inc, line 78
Provides a simple time-based caching option for panel panes.

Code

function cache_actions_rules_cache_get_id($conf, $display, $args, $contexts, $pane) {
  $id = 'rc';

  // Add some text if this is a pane, so that we don't clear all panes when
  // we clear a panel pane.
  if ($pane) {
    $id .= ':p';
  }
  if (is_numeric($display->did) && $display->did) {
    $id .= ':' . $display->did;
  }
  else {

    // Add the cache key if this is an in-code display.
    $id .= ':' . $display->cache_key;
  }

  // If this is a mini panel then we have the owner property. Let's
  // use the machine name for those.
  if (isset($display->owner)) {
    $id .= ':' . $display->owner->name;
  }
  if ($pane) {
    $id .= ':' . $pane->pid;
  }
  if (user_access('view pane admin links')) {
    $id .= ':adm';
  }
  switch ($conf['granularity']) {
    case 'args':
      foreach ($args as $arg) {

        // Arguments can be many things, but we only consider the ones that are string values.
        if (is_string($arg)) {
          $id .= ':' . $arg;
        }
      }
      break;
    case 'context':
      if (!is_array($contexts)) {
        $contexts = array(
          $contexts,
        );
      }
      foreach ($contexts as $context) {
        if (isset($context->argument)) {
          $id .= ':' . $context->argument;
        }
      }
  }

  // Add cache for individual language.
  if ($conf['language']) {
    global $language;
    $id .= ':' . $language->language;
  }
  $cache->conf = $conf;
  $cache->display = $display;
  $cache->args = $args;
  $cache->contexts = $contexts;
  $cache->pane = $pane;
  $cache->key = $id;

  // Let other modules alter the cache key.
  drupal_alter('cache_actions_panels_cache_key', $cache);
  return $cache->key;
}