1
0
Fork 0

Make sure multiple autoload files can be used together, fixes #207

pull/248/head
Jordi Boggiano 2012-01-22 22:39:54 +01:00
parent c9929a2e82
commit 7222c111ed
1 changed files with 11 additions and 6 deletions

View File

@ -27,13 +27,16 @@ class AutoloadGenerator
{ {
public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir) public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir)
{ {
$autoloadFile = file_get_contents(__DIR__.'/ClassLoader.php'); $autoloadFile = <<<'EOF'
$autoloadFile .= <<<'EOF' <?php
// autoload.php generated by Composer // autoload.php generated by Composer
if (!class_exists('Composer\\Autoload\\ClassLoader')) {
require __DIR__.'/ClassLoader.php';
}
function init() { $__composer_autoload_init = function() {
$loader = new ClassLoader(); $loader = new \Composer\Autoload\ClassLoader();
$map = require __DIR__.'/autoload_namespaces.php'; $map = require __DIR__.'/autoload_namespaces.php';
@ -44,9 +47,9 @@ function init() {
$loader->register(); $loader->register();
return $loader; return $loader;
} };
return init(); return $__composer_autoload_init();
EOF; EOF;
$filesystem = new Filesystem(); $filesystem = new Filesystem();
@ -117,6 +120,8 @@ EOF;
file_put_contents($targetDir.'/autoload.php', $autoloadFile); file_put_contents($targetDir.'/autoload.php', $autoloadFile);
file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile); file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile);
file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile);
copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
} }
/** /**