You are here

function themekey_invoke_modules in ThemeKey 7.3

Same name and namespace in other branches
  1. 6.4 themekey_base.inc \themekey_invoke_modules()
  2. 6.2 themekey_base.inc \themekey_invoke_modules()
  3. 6.3 themekey_base.inc \themekey_invoke_modules()
  4. 7 themekey_base.inc \themekey_invoke_modules()
  5. 7.2 themekey_base.inc \themekey_invoke_modules()

Invokes a hook on all modules stored in the global variable 'themekey_modules'

Parameters

$hook: name of the hook as string

Return value

mixed output of all hooks

4 calls to themekey_invoke_modules()
themekey_get_global_parameters in ./themekey_base.inc
Assigns global parameters' values to ThemeKey properties. Therefore it calls hook_themekey_global()
themekey_is_active in ./themekey.module
Indicates if ThemeKey rule chains will be evaluated.
themekey_rebuild in ./themekey_build.inc
Rebuilds all ThemeKey-related Drupal variables by calling the hooks:
themekey_ui_user_profile_form_submit in ./themekey_ui.module

File

./themekey_base.inc, line 25
The functions in this file are the back end of ThemeKey.

Code

function themekey_invoke_modules($hook) {
  $modules =& drupal_static('themekey_modules', array());
  $return = array();
  if (empty($modules)) {
    foreach (variable_get('themekey_modules', array(
      'node',
    )) as $module) {
      if (module_exists($module) && is_readable(drupal_get_path('module', 'themekey') . '/modules/themekey.' . $module . '.inc')) {
        require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey') . '/modules/themekey.' . $module . '.inc';
        $modules[] = $module;
      }
      else {

        // seems like a module has been deactivated => update variable 'themekey_modules'
        module_load_include('inc', 'themekey', 'themekey_build');
        themekey_scan_modules();
      }
    }
  }
  $args = func_get_args();

  // Remove $hook from the arguments.
  unset($args[0]);
  foreach ($modules as $module) {
    $function = 'themekey_' . $module . '_' . $hook;
    if (function_exists($function)) {
      $result = call_user_func_array($function, $args);
      if (isset($result) && is_array($result)) {
        $return = array_merge_recursive($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
  }
  return $return;
}