|
@@ -167,12 +167,6 @@ EOF;
|
|
}
|
|
}
|
|
$classmapFile .= ");\n";
|
|
$classmapFile .= ");\n";
|
|
|
|
|
|
- $filesCode = "";
|
|
|
|
- $autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files']));
|
|
|
|
- foreach ($autoloads['files'] as $functionFile) {
|
|
|
|
- $filesCode .= 'require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (!$suffix) {
|
|
if (!$suffix) {
|
|
$suffix = md5(uniqid('', true));
|
|
$suffix = md5(uniqid('', true));
|
|
}
|
|
}
|
|
@@ -182,13 +176,11 @@ EOF;
|
|
if ($includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
|
|
if ($includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
|
|
file_put_contents($targetDir.'/include_paths.php', $includePathFile);
|
|
file_put_contents($targetDir.'/include_paths.php', $includePathFile);
|
|
}
|
|
}
|
|
- if ($filesCode) {
|
|
|
|
- $filesCode = "<?php\n\n".rtrim($filesCode)."\n";
|
|
|
|
- file_put_contents($targetDir.'/autoload_files.php', $filesCode);
|
|
|
|
- $filesCode = " require __DIR__ . '/autoload_files.php';";
|
|
|
|
|
|
+ if ($includeFilesFile = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
|
|
|
|
+ file_put_contents($targetDir.'/autoload_files.php', $includeFilesFile);
|
|
}
|
|
}
|
|
file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
|
|
file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
|
|
- file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath));
|
|
|
|
|
|
+ file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath));
|
|
|
|
|
|
// use stream_copy_to_stream instead of copy
|
|
// use stream_copy_to_stream instead of copy
|
|
// to work around https://bugs.php.net/bug.php?id=64634
|
|
// to work around https://bugs.php.net/bug.php?id=64634
|
|
@@ -303,6 +295,31 @@ EOF;
|
|
return $includePathsFile . ");\n";
|
|
return $includePathsFile . ");\n";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
|
|
|
|
+ {
|
|
|
|
+ $filesCode = '';
|
|
|
|
+ $files = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($files));
|
|
|
|
+ foreach ($files as $functionFile) {
|
|
|
|
+ $filesCode .= 'require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!$filesCode) {
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+ $filesCode = rtrim($filesCode);
|
|
|
|
+
|
|
|
|
+ return <<<EOF
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+// autoload_files.php generated by Composer
|
|
|
|
+
|
|
|
|
+\$vendorDir = $vendorPathCode;
|
|
|
|
+\$baseDir = $appBaseDirCode;
|
|
|
|
+
|
|
|
|
+$filesCode
|
|
|
|
+EOF;
|
|
|
|
+ }
|
|
|
|
+
|
|
protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
|
|
protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
|
|
{
|
|
{
|
|
if (!$filesystem->isAbsolutePath($path)) {
|
|
if (!$filesystem->isAbsolutePath($path)) {
|
|
@@ -343,7 +360,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
|
|
AUTOLOAD;
|
|
AUTOLOAD;
|
|
}
|
|
}
|
|
|
|
|
|
- protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)
|
|
|
|
|
|
+ protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)
|
|
{
|
|
{
|
|
// TODO the class ComposerAutoloaderInit should be revert to a closure
|
|
// TODO the class ComposerAutoloaderInit should be revert to a closure
|
|
// when APC has been fixed:
|
|
// when APC has been fixed:
|
|
@@ -352,10 +369,6 @@ AUTOLOAD;
|
|
// - https://bugs.php.net/bug.php?id=61576
|
|
// - https://bugs.php.net/bug.php?id=61576
|
|
// - https://bugs.php.net/bug.php?id=59298
|
|
// - https://bugs.php.net/bug.php?id=59298
|
|
|
|
|
|
- if ($filesCode) {
|
|
|
|
- $filesCode = "\n\n".rtrim($filesCode);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
$file = <<<HEADER
|
|
$file = <<<HEADER
|
|
<?php
|
|
<?php
|
|
|
|
|
|
@@ -436,9 +449,22 @@ REGISTER_AUTOLOAD;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- $file .= <<<METHOD_FOOTER
|
|
|
|
- \$loader->register(true);{$filesCode}
|
|
|
|
|
|
+ $file .= <<<REGISTER_LOADER
|
|
|
|
+ \$loader->register(true);
|
|
|
|
+
|
|
|
|
|
|
|
|
+REGISTER_LOADER;
|
|
|
|
+
|
|
|
|
+ if ($useIncludeFiles) {
|
|
|
|
+ $file .= <<<INCLUDE_FILES
|
|
|
|
+ require __DIR__ . '/autoload_files.php';
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+INCLUDE_FILES;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $file .= <<<METHOD_FOOTER
|
|
return \$loader;
|
|
return \$loader;
|
|
}
|
|
}
|
|
|
|
|