You are here

function token_module_implements_alter in Token 8

Same name and namespace in other branches
  1. 7 token.module \token_module_implements_alter()

Implements hook_module_implements_alter().

Adds missing token support for core modules.

File

./token.module, line 213
Enhances the token API in core: adds a browseable UI, missing tokens, etc.

Code

function token_module_implements_alter(&$implementations, $hook) {
  \Drupal::moduleHandler()
    ->loadInclude('token', 'inc', 'token.tokens');
  if ($hook == 'tokens' || $hook == 'token_info' || $hook == 'token_info_alter' || $hook == 'tokens_alter') {
    foreach (_token_core_supported_modules() as $module) {
      if (\Drupal::moduleHandler()
        ->moduleExists($module) && function_exists($module . '_' . $hook)) {
        $implementations[$module] = TRUE;
      }
    }

    // Move token.module to get included first since it is responsible for
    // other modules.
    if (isset($implementations['token'])) {
      unset($implementations['token']);
      $implementations = array_merge([
        'token' => 'tokens',
      ], $implementations);
    }
  }
}