function ctools_context_entity_convert in Chaos Tool Suite (ctools) 7
Convert a context into a string.
1 string reference to 'ctools_context_entity_convert'
- entity.inc in plugins/
contexts/ entity.inc - Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.
File
- plugins/
contexts/ entity.inc, line 251 - Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.
Code
function ctools_context_entity_convert($context, $type, $options = array()) {
$entity_type = $context->type[2];
$entity = entity_get_info($entity_type);
if (isset($entity['token type'])) {
$token = $entity['token type'];
}
else {
$token = $entity_type;
}
// Hack: we need either token.module or a core fix for this to work right,
// until then, we just muscle it.
if ($token == 'taxonomy_term') {
$token = 'term';
}
$tokens = token_info();
$values = token_generate($token, array(
$type => $type,
), array(
$token => $context->data,
), $options);
if (isset($values[$type])) {
return $values[$type];
}
}