function panelizer_context_cache_get in Panelizer 7.2
Same name and namespace in other branches
- 6 panelizer.module \panelizer_context_cache_get()
- 7.3 panelizer.module \panelizer_context_cache_get()
- 7 panelizer.module \panelizer_context_cache_get()
Fetch the panelizer object from the object cache.
CTools clumsy context editing system requires caching. This lets us do it reasonably.
Parameters
$entity_type: Can be something like 'node' or 'user' or 'default'.
$key: Depends on the $entity_type. Can be a nid, a uid or a default key.
2 calls to panelizer_context_cache_get()
- PanelizerEntityDefault::page_context in plugins/
entity/ PanelizerEntityDefault.class.php - panelizer_default_context_page in includes/
admin.inc - Page to configure what content is available for a given node type.
1 string reference to 'panelizer_context_cache_get'
- panelizer_context.inc in plugins/
cache/ panelizer_context.inc
File
- ./
panelizer.module, line 767 - The Panelizer module attaches panels to entities, providing default panels and allowing each panel to be configured independently by privileged users.
Code
function panelizer_context_cache_get($entity_type, $key) {
ctools_include('object-cache');
$cache = ctools_object_cache_get('panelizer_context_cache', $entity_type . ':' . $key);
if (!empty($cache)) {
$cache->cached = TRUE;
return $cache;
}
if ($entity_type == 'default') {
list($entity_type, $bundle, $name) = @explode(':', $key, 3);
$get_default = TRUE;
}
if ($handler = panelizer_entity_plugin_get_handler($entity_type)) {
if (!empty($get_default)) {
$panelizer = $handler
->get_default_panelizer_object($bundle, $name);
$panelizer->base_contexts = $handler
->get_base_contexts();
return $panelizer;
}
else {
$entities = entity_load($entity_type, array(
$key,
));
if ($entities[$key] && $entities[$key]->panelizer) {
$panelizer = $entities[$key]->panelizer;
$panelizer->base_contexts = $handler
->get_base_contexts($entities[$key]);
return $panelizer;
}
}
}
}