You are here

function token_var_token_info in Token Variable 8

Same name and namespace in other branches
  1. 7 token_var.module \token_var_token_info()

Implements hook_token_info().

File

./token_var.module, line 13
Contains module code.

Code

function token_var_token_info() {
  $config = \Drupal::config('token_var.settings')
    ->get('token_var_replacements');
  $tokens = [];
  $type = array(
    'name' => t('Variables'),
    'description' => t('Tokens related to drupal variables (Only variables that contain strings can be used).'),
  );

  // Tokens.
  if (!empty($config)) {
    foreach ($config as $name => $values) {
      foreach ($values as $key => $value) {
        $tokens[$name . ':' . $key] = array(
          'name' => $name . ':' . $key,
          'description' => $name . ':' . $key,
        );
      }
    }
  }
  return array(
    'types' => array(
      'variables' => $type,
    ),
    'tokens' => array(
      'variables' => $tokens,
    ),
  );
}