You are here

function token_find_duplicate_tokens in Token 5

Same name and namespace in other branches
  1. 6 token.module \token_find_duplicate_tokens()

Find tokens that have been declared twice by different modules.

1 call to token_find_duplicate_tokens()
token_requirements in ./token.install
Implements hook_requirements().

File

./token.module, line 610
The Token API module.

Code

function token_find_duplicate_tokens() {
  token_include();
  $all_tokens = array();
  foreach (module_implements('token_list') as $module) {
    $module_tokens = module_invoke($module, 'token_list', 'all');
    if (in_array($module, array(
      'node',
      'taxonomy',
      'comment',
      'user',
    ))) {
      $module = 'token';
    }
    foreach ($module_tokens as $type => $tokens) {
      foreach (array_keys($tokens) as $token) {
        $all_tokens[$type . ':' . $token][] = $module;
      }
    }
  }
  foreach ($all_tokens as $token => $modules) {
    if (count($modules) < 2) {
      unset($all_tokens[$token]);
    }
  }
  return $all_tokens;
}