|
@@ -38,8 +38,16 @@ class AutoloadGenerator
|
|
|
*/
|
|
|
private $io;
|
|
|
|
|
|
+ /**
|
|
|
+ * @var bool
|
|
|
+ */
|
|
|
private $devMode = false;
|
|
|
|
|
|
+ /**
|
|
|
+ * @var bool
|
|
|
+ */
|
|
|
+ private $classMapAuthoritative = false;
|
|
|
+
|
|
|
public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
|
|
|
{
|
|
|
$this->eventDispatcher = $eventDispatcher;
|
|
@@ -51,8 +59,23 @@ class AutoloadGenerator
|
|
|
$this->devMode = (boolean) $devMode;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether or not generated autoloader considers the class map
|
|
|
+ * authoritative.
|
|
|
+ *
|
|
|
+ * @param bool $classMapAuthoritative
|
|
|
+ */
|
|
|
+ public function setClassMapAuthoritative($classMapAuthoritative)
|
|
|
+ {
|
|
|
+ $this->classMapAuthoritative = (boolean) $classMapAuthoritative;
|
|
|
+ }
|
|
|
+
|
|
|
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
|
|
|
{
|
|
|
+ if ($this->classMapAuthoritative) {
|
|
|
+ // Force scanPsr0Packages when classmap is authoritative
|
|
|
+ $scanPsr0Packages = true;
|
|
|
+ }
|
|
|
$this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
|
|
|
'optimize' => (bool) $scanPsr0Packages,
|
|
|
));
|
|
@@ -63,7 +86,6 @@ class AutoloadGenerator
|
|
|
$vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
|
|
|
$useGlobalIncludePath = (bool) $config->get('use-include-path');
|
|
|
$prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
|
|
|
- $classMapAuthoritative = $config->get('classmap-authoritative');
|
|
|
$targetDir = $vendorPath.'/'.$targetDir;
|
|
|
$filesystem->ensureDirectoryExists($targetDir);
|
|
|
|
|
@@ -265,7 +287,7 @@ EOF;
|
|
|
unlink($includeFilesFilePath);
|
|
|
}
|
|
|
file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
|
|
|
- file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $classMapAuthoritative));
|
|
|
+ file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader));
|
|
|
|
|
|
$this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
|
|
|
$this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
|
|
@@ -476,7 +498,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
|
|
|
AUTOLOAD;
|
|
|
}
|
|
|
|
|
|
- protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $classMapAuthoritative)
|
|
|
+ protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader)
|
|
|
{
|
|
|
// TODO the class ComposerAutoloaderInit should be revert to a closure
|
|
|
// when APC has been fixed:
|
|
@@ -553,7 +575,7 @@ PSR4;
|
|
|
CLASSMAP;
|
|
|
}
|
|
|
|
|
|
- if ($classMapAuthoritative) {
|
|
|
+ if ($this->classMapAuthoritative) {
|
|
|
$file .= <<<'CLASSMAPAUTHORITATIVE'
|
|
|
$loader->setClassMapAuthoritative(true);
|
|
|
|