You are here

function token_custom_token_info in Custom Tokens 7.2

Same name and namespace in other branches
  1. 8 token_custom.module \token_custom_token_info()
  2. 7 token_custom.module \token_custom_token_info()

Implements hook_token_info().

File

./token_custom.module, line 147
It gives the user the ability to create custom tokens using PHP code for specific replacements that can improve other modules relying on the token Drupal 7 core API.

Code

function token_custom_token_info() {
  $token_info = array();
  foreach (token_custom_type_load_multiple() as $type) {
    $token_info['types'][$type->machine_name] = array(
      'name' => $type->name,
      'description' => $type->description,
    );
  }
  foreach (token_custom_load_multiple() as $token) {
    $token_info['tokens'][$token->type][$token->machine_name] = array(
      'name' => $token->name,
      'description' => $token->description,
    );
  }
  return $token_info;
}