You are here

function _node_registration_cache in Node registration 7

Helper to make static caching prettier.

$cache_key is how this cache item is unique in drupal_static. $callback will be executed to get the cacheable if the cache item doesn't exist. $post_process will be called after the $callback is executed.

$callback doesn't take any arguments. All info needed should be included with <code>use ($var1, $var2, ...)</code>. It should return the cacheable.

$post_process takes the $cacheable and the $cache_key. It should **return** the cacheable by default. If alteration is required, return that. This argument is **not** by-reference.

2 calls to _node_registration_cache()
node_registration_access in includes/node_registration.api.inc
All Registration access callbacks. Just like node.module has node_access.
node_registration_node_access in includes/node_registration.api.inc
Implements hook_node_access().

File

./node_registration.module, line 1266

Code

function _node_registration_cache($cache_key, $callback, $post_process = null) {
  $cache =& drupal_static($cache_key);
  if (!isset($cache)) {
    $cache = $callback();
    if (is_callable($post_process)) {
      $cache = $post_process($cache, $cache_key);
    }
  }
  return $cache;
}