You are here

function field_collection_token_info in Field collection 7

Implements hook_token_info().

File

./field_collection.tokens.inc, line 11
Provides host entity tokens for field_collection.module.

Code

function field_collection_token_info() {
  $type = array(
    'name' => t('Field collection host entity'),
    'description' => t('Tokens related to field collection host entities.'),
    'needs-data' => 'field_collection_item',
  );

  // Simple tokens.
  $host['type'] = array(
    'name' => t('Host entity type'),
    'description' => t('The entity type of the host. Common types are <em>node</em> and <em>user</em>.'),
  );
  $host['bundle'] = array(
    'name' => t('Host entity bundle'),
    'description' => t('For <em>node</em> entity types this is the content type, otherwise available as <code>[node:content-type:machine-name]</code>.'),
  );
  $host['id'] = array(
    'name' => t('Host entity ID'),
    'description' => t('The entity ID of the host. For nodes this is <code>nid</code>, for users <code>uid</code>.'),
  );
  $host['delta'] = array(
    'name' => t('Host entity item delta'),
    'description' => t('The delta of the reference pointing to this field collection item.'),
  );

  // Chained tokens.
  foreach (field_collection_host_entity_types() as $entity_type => $entity_info) {
    $host[$entity_type] = array(
      'name' => t('Entity: @entity_type', array(
        '@entity_type' => $entity_info['label'],
      )),
      'description' => t('Host entity tokens when it is of type %entity_type', array(
        '%entity_type' => $entity_info['label'],
      )),
      'type' => $entity_type,
    );
  }
  return array(
    'types' => array(
      'host' => $type,
    ),
    'tokens' => array(
      'host' => $host,
    ),
  );
}