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

Breadcrumb

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

function AutoloadGenerator::getIncludePathsFile

Parameters

array<int, array{0: PackageInterface, 1: string|null}> $packageMap:

Return value

?string

1 call to AutoloadGenerator::getIncludePathsFile()
AutoloadGenerator::dump in vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php

File

vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php, line 650

Class

AutoloadGenerator
@author Igor Wiedler <igor@wiedler.ch> @author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Autoload

Code

protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode) {
    $includePaths = [];
    foreach ($packageMap as $item) {
        [
            $package,
            $installPath,
        ] = $item;
        // packages that are not installed cannot autoload anything
        if (null === $installPath) {
            continue;
        }
        if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
            $installPath = substr($installPath, 0, -strlen('/' . $package->getTargetDir()));
        }
        foreach ($package->getIncludePaths() as $includePath) {
            $includePath = trim($includePath, '/');
            $includePaths[] = $installPath === '' ? $includePath : $installPath . '/' . $includePath;
        }
    }
    if (\count($includePaths) === 0) {
        return null;
    }
    $includePathsCode = '';
    foreach ($includePaths as $path) {
        $includePathsCode .= "    " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
    }
    return <<<EOF
<?php

// include_paths.php @generated by Composer

\$vendorDir = {<span class="php-variable">$vendorPathCode</span>};
\$baseDir = {<span class="php-variable">$appBaseDirCode</span>};

return array(
{<span class="php-variable">$includePathsCode</span>});

EOF;
}

API Navigation

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