You are here

abstract class AbstractClassLoader in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/ClassLoader/AbstractClassLoader.php \Drupal\xautoload\ClassLoader\AbstractClassLoader

Behaves mostly like the Symfony ClassLoader classes.

Hierarchy

Expanded class hierarchy of AbstractClassLoader

2 files declare their use of AbstractClassLoader
ClassFinder.php in src/ClassFinder/ClassFinder.php
ProxyClassFinder.php in src/ClassFinder/ProxyClassFinder.php

File

src/ClassLoader/AbstractClassLoader.php, line 8

Namespace

Drupal\xautoload\ClassLoader
View source
abstract class AbstractClassLoader implements ClassLoaderInterface {

  /**
   * Registers this instance as an autoloader.
   *
   * @param boolean $prepend
   *   If TRUE, the loader will be prepended. Otherwise, it will be appended.
   */
  function register($prepend = FALSE) {

    // http://www.php.net/manual/de/function.spl-autoload-register.php#107362
    // "when specifying the third parameter (prepend), the function will fail badly in PHP 5.2"
    if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
      spl_autoload_register(array(
        $this,
        'loadClass',
      ), TRUE, $prepend);
    }
    elseif ($prepend) {
      $loaders = spl_autoload_functions();
      spl_autoload_register(array(
        $this,
        'loadClass',
      ));
      foreach ($loaders as $loader) {
        spl_autoload_unregister($loader);
        spl_autoload_register($loader);
      }
    }
    else {
      spl_autoload_register(array(
        $this,
        'loadClass',
      ));
    }
  }

  /**
   * Unregister from the spl autoload stack.
   */
  function unregister() {
    spl_autoload_unregister(array(
      $this,
      'loadClass',
    ));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractClassLoader::register function Registers this instance as an autoloader. Overrides ClassLoaderInterface::register
AbstractClassLoader::unregister function Unregister from the spl autoload stack. Overrides ClassLoaderInterface::unregister
ClassLoaderInterface::loadClass function Callback for class loading. This will include ("require") the file found. 3