You are here

function _xautoload_register in X Autoload 7.5

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

Creates and registers the xautoload class loader.

Registers the xautoload_ prefix and the Drupal\xautoload\\ namespace, but does not register any other Drupal-specific stuff yet. This is because this might be called from settings.php, while some parts of Drupal are not fully initialized yet.

3 calls to _xautoload_register()
bootstrap.php in tests/bootstrap.php
xautoload.early.inc in ./xautoload.early.inc
_xautoload_register_drupal in ./xautoload.module
Registers Drupal-related namespaces and prefixes in the xautoload loader, and activates the APC (or similar) cache, if enabled.

File

./xautoload.early.lib.inc, line 74

Code

function _xautoload_register() {

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

  // Register a temporary loader.
  spl_autoload_register('_xautoload_autoload_temp', TRUE, TRUE);

  // Some classes need to be loaded manually. Believe it!
  LoadClassInjectedAPI::forceAutoload();
  LoadClassGetFileInjectedApi::forceAutoload();
  \Drupal\xautoload\Util::forceAutoload();
  $finder = xautoload()->finder;
  $finder
    ->register();

  // Register the 'Drupal\xautoload\\' namespace.
  $finder
    ->addPsr4('Drupal\\xautoload\\', XAUTOLOAD_SRC_DIR . '/');

  // Register the "xautoload_" prefix for legacy classes.
  $finder
    ->addPearFlat('xautoload_', __DIR__ . '/legacy/lib/');

  // Unregister the temporary loader.
  spl_autoload_unregister('_xautoload_autoload_temp');
}