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

Breadcrumb

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

function AutoloadGenerator::getIncludeFilesFile

Parameters

array<string, string> $files:

Return value

?string

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

File

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

Class

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

Namespace

Composer\Autoload

Code

protected function getIncludeFilesFile(array $files, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode) {
    // Get the path to each file, and make sure these paths are unique.
    $files = array_map(function (string $functionFile) use ($filesystem, $basePath, $vendorPath) : string {
        return $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile);
    }, $files);
    $uniqueFiles = array_unique($files);
    if (count($uniqueFiles) < count($files)) {
        $this->io
            ->writeError('<warning>The following "files" autoload rules are included multiple times, this may cause issues and should be resolved:</warning>');
        foreach (array_unique(array_diff_assoc($files, $uniqueFiles)) as $duplicateFile) {
            $this->io
                ->writeError('<warning> - ' . $duplicateFile . '</warning>');
        }
    }
    unset($uniqueFiles);
    $filesCode = '';
    foreach ($files as $fileIdentifier => $functionFile) {
        $filesCode .= '    ' . var_export($fileIdentifier, true) . ' => ' . $functionFile . ",\n";
    }
    if (!$filesCode) {
        return null;
    }
    return <<<EOF
<?php

// autoload_files.php @generated by Composer

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

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

EOF;
}

API Navigation

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