1
0
Fork 0

Restore bindir/vendordir behavior, fixes #216

pull/198/head^2
Jordi Boggiano 2012-01-17 11:54:02 +01:00
parent b97067c618
commit 3bed815b19
1 changed files with 7 additions and 14 deletions

View File

@ -23,8 +23,6 @@ use Composer\Json\JsonFile;
*/ */
class Factory class Factory
{ {
protected $vendorDir;
/** /**
* Creates a Composer instance * Creates a Composer instance
* *
@ -48,8 +46,6 @@ class Factory
throw new \InvalidArgumentException($message.PHP_EOL.$instructions); throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
} }
$baseDir = rtrim(dirname($composerFile), '/').'/';
// Configuration defaults // Configuration defaults
$composerConfig = array( $composerConfig = array(
'vendor-dir' => 'vendor', 'vendor-dir' => 'vendor',
@ -69,9 +65,6 @@ class Factory
} }
$binDir = getenv('COMPOSER_BIN_DIR') ?: $packageConfig['config']['bin-dir']; $binDir = getenv('COMPOSER_BIN_DIR') ?: $packageConfig['config']['bin-dir'];
$this->vendorDir = $baseDir.$vendorDir;
$this->binDir = $baseDir.$binDir;
// initialize repository manager // initialize repository manager
$rm = $this->createRepositoryManager(); $rm = $this->createRepositoryManager();
@ -79,7 +72,7 @@ class Factory
$dm = $this->createDownloadManager(); $dm = $this->createDownloadManager();
// initialize installation manager // initialize installation manager
$im = $this->createInstallationManager($rm, $dm); $im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir);
// load package // load package
$loader = new Package\Loader\RootPackageLoader($rm); $loader = new Package\Loader\RootPackageLoader($rm);
@ -105,10 +98,10 @@ class Factory
return $composer; return $composer;
} }
protected function createRepositoryManager() protected function createRepositoryManager($vendorDir)
{ {
$rm = new Repository\RepositoryManager(); $rm = new Repository\RepositoryManager();
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($this->vendorDir.'/.composer/installed.json'))); $rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository'); $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
@ -129,11 +122,11 @@ class Factory
return $dm; return $dm;
} }
protected function createInstallationManager(Repository\RepositoryManager $rm, Downloader\DownloadManager $dm) protected function createInstallationManager(Repository\RepositoryManager $rm, Downloader\DownloadManager $dm, $vendorDir, $binDir)
{ {
$im = new Installer\InstallationManager($this->vendorDir); $im = new Installer\InstallationManager($vendorDir);
$im->addInstaller(new Installer\LibraryInstaller($this->vendorDir, $this->binDir, $dm, $rm->getLocalRepository(), null)); $im->addInstaller(new Installer\LibraryInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), null));
$im->addInstaller(new Installer\InstallerInstaller($this->vendorDir, $this->binDir, $dm, $rm->getLocalRepository(), $im)); $im->addInstaller(new Installer\InstallerInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $im));
return $im; return $im;
} }