function entity_token_types_chained in Entity API 7
Defines a list of token types that need to be chained.
Return value
bool|array If a (token) type is given, whether the given type needs to be chained. Else a full list of token types to be chained as returned by entity_token_token_types().
3 calls to entity_token_types_chained()
- 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().
- entity_token_types in ./
entity_token.tokens.inc - Defines the types of properties to be added as token.
File
- ./
entity_token.tokens.inc, line 27 - Provides tokens for entity properties which have no token yet.
Code
function entity_token_types_chained($type = NULL) {
// This functions gets called rather often when replacing tokens, thus
// we statically cache $types using the advanced drupal static pattern.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['types'] =& drupal_static(__FUNCTION__, array());
}
$types =& $drupal_static_fast['types'];
if (!$types) {
// Add entities.
foreach (entity_get_info() as $entity_type => $info) {
if ($token_type = isset($info['token type']) ? $info['token type'] : $entity_type) {
$types[$token_type] = $entity_type;
}
}
// Add 'date' and 'site' tokens.
$types['date'] = 'date';
$types['site'] = 'site';
// Add a 'struct' type.
$types['struct'] = 'struct';
}
if (isset($type)) {
return isset($types[$type]) || entity_property_list_extract_type($type);
}
return $types;
}