You are here

function domain_api in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain.module \domain_api()
  2. 6.2 domain.module \domain_api()
  3. 7.2 domain.module \domain_api()

Helper function for passing hook_domain_load() by reference.

Parameters

$domain: The domain array defined by domain_lookup().

$reset: A boolean flag indicating whether to reset the static array or not.

Return value

The $domain array, modified by reference by hook_domain_load() implementations.

4 calls to domain_api()
domain_default in ./domain.module
Assigns the default settings to domain 0, the root domain.
domain_lookup in ./domain.module
Runs a lookup against the {domain} table.
domain_machine_name_load in ./domain.module
Loads a domain from its machine name.
domain_overview_form in ./domain.admin.inc
Create an overview form for sorting domains and other quick actions.

File

./domain.module, line 1474
Core module functions for the Domain Access suite.

Code

function domain_api($domain, $reset = FALSE) {
  $modules =& drupal_static(__FUNCTION__);

  // There are rare cases where the module_implements() cache is built too early.
  // In these cases, it is the pre-loaded bootstrap modules that can cause
  // issues, so let's be certain to load those.
  if (!isset($modules) || $reset) {
    $modules = module_implements('domain_load');
    if (function_exists('_domain_bootstrap_modules')) {
      $bootstrap = _domain_bootstrap_modules();
      $modules = array_unique(array_merge($modules, $bootstrap));
    }
    elseif (!variable_get('domain_hide_errors')) {

      // Not reporting an error during install makes it easier for scripts.
      $severity = drupal_installation_attempted() ? 'warning' : 'error';
      drupal_set_message(t('Domain module installation is incomplete. See INSTALL.txt and check your settings.php file.'), $severity, FALSE);
    }
  }

  // Now, call the hook invocations.
  if (!empty($modules)) {
    foreach ($modules as $module) {

      // Do not, however, call disabled modules ;-).
      if (module_exists($module)) {

        // Cannot use module_invoke_all() since these are passed by reference.
        $function = $module . '_domain_load';
        module_load_include('inc', $module, $module . '.domain');
        if (function_exists($function)) {
          $function($domain);
        }
      }
    }
  }
  return $domain;
}