function views_content_cache_key_og::content_key in Views content cache 7.3
Same name and namespace in other branches
- 6.2 plugins/og.inc \views_content_cache_key_og::content_key()
Builds an array of keys for the cache segment.
When an 'event' happens, e.g. a node is saved, views content cache will consult this plugin for the keys it wishes to store in its cache segments. Views content cache will then handle the storage.
Parameters
$object: The object that is being changed.
$object_type: The type of the object that is being changed.
Return value
Either a scalar value or an array of scalars. These should be the different keys that are effected by the event in this cache segment.
Overrides views_content_cache_key::content_key
File
- plugins/
views_content_cache/ og.inc, line 28 - Provides the Views content cache OG plugin.
Class
- views_content_cache_key_og
- Views content cache plugin for Organic Groups.
Code
function content_key($object, $object_type) {
$keys = array();
if ($object_type === 'node' && !empty($object->og_groups)) {
foreach ($object->og_groups as $gid) {
$keys[] = $gid;
}
}
elseif ($object_type === 'comment' && !empty($object->nid) && ($node = node_load($object->nid)) && !empty($node->og_groups)) {
foreach ($node->og_groups as $gid) {
$keys[] = $gid;
}
}
return $keys;
}