function _entity_token_map_to_token_type in Entity API 7
Gets the right token type for a given property info array.
2 calls to _entity_token_map_to_token_type()
- entity_token_tokens in ./
entity_token.tokens.inc - Implements hook_tokens().
- entity_token_token_info_alter in ./
entity_token.tokens.inc - Implements hook_token_info_alter().
File
- ./
entity_token.tokens.inc, line 59 - Provides tokens for entity properties which have no token yet.
Code
function _entity_token_map_to_token_type($property_info) {
$lookup =& drupal_static(__FUNCTION__);
if (!$lookup) {
// Initialize a lookup array mapping property types to token types.
$lookup = array_flip(entity_token_types());
}
$type = isset($property_info['type']) ? $property_info['type'] : 'text';
// Just use the type 'struct' for all structures.
if (!empty($property_info['property info'])) {
$type = 'struct';
}
if ($item_type = entity_property_list_extract_type($type)) {
return isset($lookup[$item_type]) ? "list<{$lookup[$item_type]}>" : FALSE;
}
return isset($lookup[$type]) ? $lookup[$type] : FALSE;
}