Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ClassLoader.php

function ClassLoader::setPsr4

Same name in this branch
  1. 11.1.x vendor/composer/ClassLoader.php \Composer\Autoload\ClassLoader::setPsr4()

Registers a set of PSR-4 directories for a given namespace, replacing any others previously set for this namespace.

Parameters

string $prefix The prefix/namespace, with trailing '\\':

list<string>|string $paths The PSR-4 base directories:

Return value

void

Throws

\InvalidArgumentException

File

vendor/composer/composer/src/Composer/Autoload/ClassLoader.php, line 298

Class

ClassLoader
ClassLoader implements a PSR-0, PSR-4 and classmap class loader.

Namespace

Composer\Autoload

Code

public function setPsr4($prefix, $paths) {
    if (!$prefix) {
        $this->fallbackDirsPsr4 = (array) $paths;
    }
    else {
        $length = strlen($prefix);
        if ('\\' !== $prefix[$length - 1]) {
            throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
        }
        $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
        $this->prefixDirsPsr4[$prefix] = (array) $paths;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal