You are here

function _xautoload_register in X Autoload 7.4

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

Create and register the xautoload class loader. Register the xautoload prefix, but don't register any Drupal-specific stuff 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
Register Drupal-related namespaces and prefixes in the xautoload loader.

File

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

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');

  // Some classes need to be loaded manually. Believe it!
  LoadClassInjectedAPI::forceAutoload();
  LoadClassGetFileInjectedApi::forceAutoload();
  \Drupal\xautoload\Util::forceAutoload();

  /**
   * @var ExtendedClassFinderInterface $finder
   */
  $finder = xautoload()->finder;
  $finder
    ->register();

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

  // Register the "xautoload_" prefix.
  $finder
    ->getPrefixMap()
    ->registerDeepPath('xautoload/', __DIR__ . '/legacy/lib/', new DefaultDirectoryBehavior());

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