You are here

function token_find_duplicate_tokens in Token 6

Same name and namespace in other branches
  1. 5 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 792
The Token API module.

Code

function token_find_duplicate_tokens() {
  token_include();
  $all_tokens = array();
  foreach (module_implements('token_list') as $module) {
    $module_token_list = module_invoke($module, 'token_list', 'all');
    if (!isset($module_token_list) || !is_array($module_token_list)) {

      // Skip modules that do not return an array as that is a valid return
      // value.
      continue;
    }
    if (in_array($module, _token_core_supported_modules())) {
      $module = 'token';
    }
    foreach ($module_token_list 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;
}