You are here

function token_field_info_alter in Token 8

Same name and namespace in other branches
  1. 7 token.module \token_field_info_alter()

Implements hook_field_info_alter().

File

./token.module, line 109
Enhances the token API in core: adds a browseable UI, missing tokens, etc.

Code

function token_field_info_alter(&$info) {
  $defaults = [
    'taxonomy_term_reference' => 'taxonomy_term_reference_plain',
    'number_integer' => 'number_unformatted',
    'number_decimal' => 'number_unformatted',
    'number_float' => 'number_unformatted',
    'file' => 'file_url_plain',
    'image' => 'file_url_plain',
    'text' => 'text_default',
    'text_long' => 'text_default',
    'text_with_summary' => 'text_default',
    'list_integer' => 'list_default',
    'list_float' => 'list_default',
    'list_string' => 'list_default',
    'list_boolean' => 'list_default',
  ];
  foreach ($defaults as $field_type => $default_token_formatter) {
    if (isset($info[$field_type])) {
      $info[$field_type] += [
        'default_token_formatter' => $default_token_formatter,
      ];
    }
  }
}