You are here

function views_content_cache_id_generate in Views content cache 6.2

Same name and namespace in other branches
  1. 7.3 views_content_cache.module \views_content_cache_id_generate()

Generate one or more cache ids for an update record.

Parameters

object $object: The object for which the update is occurring. Example: a $node object.

string $object_type: A string identifier that other modules can use to identify the type of object passed to them. Example: 'node'.

Return value

array Returns an array of cache ids.

1 call to views_content_cache_id_generate()
views_content_cache_update_set in ./views_content_cache.module
Create one or more update records for the given object.

File

./views_content_cache.module, line 243
Views content cache cache.

Code

function views_content_cache_id_generate($object, $object_type) {
  $cids = array(
    array(),
  );
  foreach (views_content_cache_get_plugin() as $key_id => $plugin) {
    $key_values = $plugin
      ->content_key($object, $object_type);
    if (!empty($key_values)) {

      // Ensure that we have an array to work with.
      $key_values = is_array($key_values) ? $key_values : array(
        $key_values,
      );

      // If the content key is multivalue create an additional cid per value.
      $processed = array();
      foreach ($key_values as $key_value) {
        foreach ($cids as $cid) {
          $cid[$key_id] = $key_value;
          $processed[] = $cid;
        }
      }
      $cids = $processed;
    }
  }
  return $cids;
}