You are here

function js_custom_theme in JS Callback Handler 7.2

Implements hook_custom_theme().

File

./js.module, line 106
JavaScript callback handler module.

Code

function js_custom_theme() {
  global $_js;

  // During a full bootstrap, hook_custom_theme() is invoked just before
  // hook_init(). Here we can make sure that hook_init() implementations
  // provided by callback dependencies are not invoked twice, in case a full
  // bootstrap is performed after invoking them in js_callback_bootstrap().
  if (!empty($_js['module']) && !empty($_js['callback'])) {
    $info = js_get_callback($_js['module'], $_js['callback']);
    if (!$info['skip init'] && $info['dependencies']) {
      $implementations =& drupal_static('module_implements');

      // After a global cache clear, hook implementation info is not available
      // yet, so we explicitly rebuild it.
      if (!isset($implementations['init'])) {
        module_implements('init');
      }
      $implementations['init'] = array_diff_key($implementations['init'], array_flip($info['dependencies']));
    }
  }

  // Set the theme to be used for JS requests.
  if (!empty($_js['theme'])) {
    return $_js['theme'];
  }
}