1
0
Fork 0

Merge remote-tracking branch 'Devolicious/feature/no-prepend'

pull/2316/merge
Jordi Boggiano 2013-10-16 12:15:36 +02:00
commit 7682bc0d60
2 changed files with 6 additions and 4 deletions

View File

@ -46,6 +46,7 @@ class AutoloadGenerator
$basePath = $filesystem->normalizePath(getcwd()); $basePath = $filesystem->normalizePath(getcwd());
$vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir'))); $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
$useGlobalIncludePath = (bool) $config->get('use-include-path'); $useGlobalIncludePath = (bool) $config->get('use-include-path');
$prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
$targetDir = $vendorPath.'/'.$targetDir; $targetDir = $vendorPath.'/'.$targetDir;
$filesystem->ensureDirectoryExists($targetDir); $filesystem->ensureDirectoryExists($targetDir);
@ -180,7 +181,7 @@ EOF;
file_put_contents($targetDir.'/autoload_files.php', $includeFilesFile); 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, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)); file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader));
// 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
@ -365,7 +366,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
AUTOLOAD; AUTOLOAD;
} }
protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath) protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader)
{ {
// 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:
@ -396,7 +397,7 @@ class ComposerAutoloaderInit$suffix
return self::\$loader; return self::\$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(); self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
@ -455,7 +456,7 @@ REGISTER_AUTOLOAD;
} }
$file .= <<<REGISTER_LOADER $file .= <<<REGISTER_LOADER
\$loader->register(true); \$loader->register($prependAutoloader);
REGISTER_LOADER; REGISTER_LOADER;

View File

@ -35,6 +35,7 @@ class Config
'cache-files-ttl' => null, // fallback to cache-ttl 'cache-files-ttl' => null, // fallback to cache-ttl
'cache-files-maxsize' => '300MiB', 'cache-files-maxsize' => '300MiB',
'discard-changes' => false, 'discard-changes' => false,
'prepend-autoloader' => true,
); );
public static $defaultRepositories = array( public static $defaultRepositories = array(