1
0
Fork 0

Minor adjustments to merged PR

pull/122/merge
Jordi Boggiano 2011-11-20 22:02:22 +01:00
parent 5b87a02767
commit f5b7e968b2
5 changed files with 20 additions and 19 deletions

View File

@ -35,12 +35,11 @@ if (isset($packageConfig['config']) && is_array($packageConfig['config'])) {
$packageConfig['config'] = $composerConfig;
}
// easy local access
$vendorPath = $packageConfig['config']['vendor-dir'];
$vendorDir = $packageConfig['config']['vendor-dir'];
// initialize repository manager
$rm = new Repository\RepositoryManager();
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorPath.'/.composer/installed.json')));
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
@ -55,9 +54,9 @@ $dm->setDownloader('pear', new Downloader\PearDownloader());
$dm->setDownloader('zip', new Downloader\ZipDownloader());
// initialize installation manager
$im = new Installer\InstallationManager($vendorPath);
$im->addInstaller(new Installer\LibraryInstaller($vendorPath, $dm, $rm->getLocalRepository(), null));
$im->addInstaller(new Installer\InstallerInstaller($vendorPath, $dm, $rm->getLocalRepository(), $im));
$im = new Installer\InstallationManager($vendorDir);
$im->addInstaller(new Installer\LibraryInstaller($vendorDir, $dm, $rm->getLocalRepository(), null));
$im->addInstaller(new Installer\InstallerInstaller($vendorDir, $dm, $rm->getLocalRepository(), $im));
// load package
$loader = new Package\Loader\ArrayLoader($rm);

View File

@ -54,6 +54,8 @@ EOF;
// autoload_namespace.php generated by Composer
$baseDir = dirname(__DIR__);
return array(
EOF;
@ -77,7 +79,7 @@ EOF;
foreach ($autoloads['psr-0'] as $def) {
if (!$this->isAbsolutePath($def['path'])) {
$def['path'] = substr($def['path'], strlen($vendorPath));
$baseDir = "dirname(__DIR__).";
$baseDir = '$baseDir . ';
} else {
$baseDir = '';
}

View File

@ -33,20 +33,20 @@ class InstallationManager
/**
* Creates an instance of InstallationManager
*
* @param string $vendorPath Relative path to the vendor directory
* @param string $vendorDir Relative path to the vendor directory
* @throws \InvalidArgumentException
*/
public function __construct($vendorPath = 'vendor')
public function __construct($vendorDir = 'vendor')
{
if (substr($vendorPath, 0, 1) === '/' || substr($vendorPath, 1, 1) === ':') {
if (substr($vendorDir, 0, 1) === '/' || substr($vendorDir, 1, 1) === ':') {
$basePath = getcwd();
if (0 !== strpos($vendorPath, $basePath)) {
throw new \InvalidArgumentException("Vendor path ($vendorPath) must be within the current working directory ($basePath).");
if (0 !== strpos($vendorDir, $basePath)) {
throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath).");
}
// convert to relative path
$this->vendorPath = substr($vendorPath, strlen($basePath)+1);
$this->vendorPath = substr($vendorDir, strlen($basePath)+1);
} else {
$this->vendorPath = $vendorPath;
$this->vendorPath = $vendorDir;
}
}

View File

@ -209,7 +209,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
public function testGetVendorPathAbsolute()
{
$manager = new InstallationManager('vendor');
$this->assertEquals(realpath('').DIRECTORY_SEPARATOR.'vendor', $manager->getVendorPath(true));
$this->assertEquals(getcwd().DIRECTORY_SEPARATOR.'vendor', $manager->getVendorPath(true));
}
public function testGetVendorPathRelative()