1
0
Fork 0

Fix autoload handling of main project

pull/122/merge
Jordi Boggiano 2011-11-21 11:33:30 +01:00
parent f5b7e968b2
commit cb44ba8325
2 changed files with 13 additions and 4 deletions

View File

@ -75,11 +75,20 @@ EOF;
$autoloads = $this->parseAutoloads($packageMap); $autoloads = $this->parseAutoloads($packageMap);
$vendorPath = $installationManager->getVendorPath(); $vendorPath = $installationManager->getVendorPath();
$realVendorPath = realpath($vendorPath);
$vendorPathDepth = substr_count(strtr(substr($realVendorPath, strlen(getcwd())), '\\', '/'), '/');
$appBaseDir = str_repeat('dirname(', $vendorPathDepth).'$baseDir'.str_repeat(')', $vendorPathDepth);
if (isset($autoloads['psr-0'])) { if (isset($autoloads['psr-0'])) {
foreach ($autoloads['psr-0'] as $def) { foreach ($autoloads['psr-0'] as $def) {
if (!$this->isAbsolutePath($def['path'])) { if (!$this->isAbsolutePath($def['path'])) {
if (strpos($def['path'], $vendorPath) === 0) {
$def['path'] = substr($def['path'], strlen($vendorPath)); $def['path'] = substr($def['path'], strlen($vendorPath));
$baseDir = '$baseDir . '; $baseDir = '$baseDir . ';
} else {
$def['path'] = '/'.$def['path'];
$baseDir = $appBaseDir . ' . ';
}
} else { } else {
$baseDir = ''; $baseDir = '';
} }

View File

@ -44,9 +44,9 @@ class InstallationManager
throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath)."); throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath).");
} }
// convert to relative path // convert to relative path
$this->vendorPath = substr($vendorDir, strlen($basePath)+1); $this->vendorPath = rtrim(substr($vendorDir, strlen($basePath)+1), '/');
} else { } else {
$this->vendorPath = $vendorDir; $this->vendorPath = rtrim($vendorDir, '/');
} }
} }