function metatag_cache_default_cid_parts in Metatag 7
Generate the cache ID to use with metatag_cache_get/metatag_cache_set calls.
Parameters
array $cid_parts: A list of values to be used.
Return value
string The cache ID string.
2 calls to metatag_cache_default_cid_parts()
- metatag_generate_entity_metatags in ./
metatag.module - Generate the metatags for a given entity.
- metatag_page_build in ./
metatag.module - Implements hook_page_build().
File
- ./
metatag.module, line 2796 - Primary hook implementations for Metatag.
Code
function metatag_cache_default_cid_parts(array $cid_parts = array()) {
// The initial parts, control the order of the parts.
$cid_part_defaults = array(
'cache_type' => 'output',
'instance' => '',
'entity_type' => '',
'entity_id' => '',
'bundle' => '',
'langcode' => $GLOBALS['language_content']->language,
'revision_id' => '',
'view_mode' => '',
'status' => 200,
'protocol' => $GLOBALS['is_https'] ? 'https' : 'http',
'hostname' => $_SERVER['HTTP_HOST'],
'base_path' => base_path(),
);
$cid_parts = array_merge($cid_part_defaults, $cid_parts);
// Add the HTTP status code.
$headers = drupal_get_http_header();
if (isset($headers['status'])) {
$cid_parts['status'] = intval($headers['status']);
}
// Allow each page in a sequence to have different values.
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$cid_parts['page'] = intval($_GET['page']);
}
// Allow other modules to customize the data using
// hook_metatag_page_cache_cid_parts_alter().
drupal_alter('metatag_page_cache_cid_parts', $cid_parts);
// Remove empty parts.
$cid_parts = array_filter($cid_parts);
// Concatenate the cache ID parts, trim the results to 255 chars.
return substr(implode(':', $cid_parts), 0, 255);
}