You are here

function _xautoload_register in X Autoload 7.2

Same name and namespace in other branches
  1. 7.5 xautoload.early.lib.inc \_xautoload_register()
  2. 7.3 xautoload.early.inc \_xautoload_register()
  3. 7.4 xautoload.early.lib.inc \_xautoload_register()

Build and register the xautoload loader.

1 call to _xautoload_register()
xautoload.module in ./xautoload.module

File

./xautoload.module, line 263

Code

function _xautoload_register() {

  // Check that this runs only once.
  static $_first_run = TRUE;
  if (!$_first_run) {
    return;
  }
  $_first_run = FALSE;

  // Register a temporary solution.
  spl_autoload_register('_xautoload_autoload_temp');

  // This one class needs to be loaded manually.
  // Just believe me on that one.
  _xautoload_autoload_temp('xautoload_InjectedAPI_findFile');

  // Register the "real" class loader.
  xautoload('classLoader')
    ->register(TRUE);

  // The "extension system" needs some babysitting.
  // Let's start by filling it with the boot-level modules.
  xautoload('drupalExtensionSystem')
    ->bootstrapPhase();

  // Unregister our temporary solution.
  spl_autoload_unregister('_xautoload_autoload_temp');

  // if xautoload has just been enabled, it won't be listed as a boot-level
  // module. To be sure, we register its namespace explicitly.
  if (!module_exists('xautoload') && function_exists('drupal_get_path')) {
    $lib_dir = drupal_get_path('module', 'xautoload') . '/lib';
    xautoload('classFinder')
      ->registerPrefixDeep('xautoload', $lib_dir);
  }

  // Let's crash right here if it doesn't work.
  new xautoload_InjectedAPI_hookXautoload(xautoload('classFinder'));
}