function BackwardsCompatibilityClassLoader::loadClass

Aliases a moved class to another class, instead of actually autoloading it.

Parameters

string $class: The classname to load.

File

core/lib/Drupal/Core/ClassLoader/BackwardsCompatibilityClassLoader.php, line 20

Class

BackwardsCompatibilityClassLoader
Adds backwards compatibility support for deprecated classes.

Namespace

Drupal\Core\ClassLoader

Code

public function loadClass(string $class) : void {
  if (isset($this->movedClasses[$class])) {
    $moved = $this->movedClasses[$class];
    if (isset($moved['deprecation_version']) && isset($moved['removed_version']) && isset($moved['change_record'])) {
      // @phpcs:ignore
      @trigger_error(sprintf('Class %s is deprecated in %s and is removed from %s, use %s instead. See %s', $class, $moved['deprecation_version'], $moved['removed_version'], $moved['class'], $moved['change_record']), E_USER_DEPRECATED);
    }
    class_alias($moved['class'], $class, TRUE);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.