You are here

function token_custom_token_info in Custom Tokens 8

Same name and namespace in other branches
  1. 7.2 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 17
Hooks for Custom Tokens module.

Code

function token_custom_token_info() {
  $types = [];
  foreach (TokenCustomType::loadMultiple() as $token_type) {
    $types[$token_type
      ->id()] = [
      'name' => $token_type->name,
      'description' => $token_type->description,
    ];
  }
  $tokens = [];
  foreach (TokenCustom::loadMultiple() as $token) {
    $tokens[$token
      ->bundle()][$token
      ->id()] = [
      'name' => $token
        ->label(),
      'description' => $token
        ->getDescription(),
    ];
  }
  return [
    'types' => $types,
    'tokens' => $tokens,
  ];
}