1
0
Fork 0

Fixed creating shortest paths in AutoloadGenerator

pull/484/head
Martin Hasoň 2012-03-21 14:29:24 +01:00
parent fde38dacec
commit afc04c9e53
1 changed files with 3 additions and 7 deletions

View File

@ -58,7 +58,7 @@ EOF;
$filesystem = new Filesystem(); $filesystem = new Filesystem();
$vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/'); $vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/');
$relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath); $relVendorPath = $filesystem->findShortestPath(getcwd().'/inDir', $vendorPath);
$vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); $vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
$appBaseDir = $filesystem->findShortestPathCode($vendorPath, getcwd(), true); $appBaseDir = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
@ -85,11 +85,7 @@ EOF;
$path = strtr($path, '\\', '/'); $path = strtr($path, '\\', '/');
$baseDir = ''; $baseDir = '';
if (!$filesystem->isAbsolutePath($path)) { if (!$filesystem->isAbsolutePath($path)) {
// vendor dir == working dir if (strpos($path, $relVendorPath) === 0) {
if (preg_match('{^(\./?)?$}', $relVendorPath)) {
$path = '/'.$path;
$baseDir = '$vendorDir . ';
} elseif (strpos($path, $relVendorPath) === 0) {
// path starts with vendor dir // path starts with vendor dir
$path = substr($path, strlen($relVendorPath)); $path = substr($path, strlen($relVendorPath));
$baseDir = '$vendorDir . '; $baseDir = '$vendorDir . ';
@ -129,7 +125,7 @@ EOF;
$autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap'])); $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap']));
foreach ($autoloads['classmap'] as $dir) { foreach ($autoloads['classmap'] as $dir) {
foreach (ClassMapGenerator::createMap($dir) as $class => $path) { foreach (ClassMapGenerator::createMap($dir) as $class => $path) {
$path = '/'.$filesystem->findShortestPath(getcwd(), $path); $path = '/'.$filesystem->findShortestPath(getcwd().'/inDir', $path);
$classmapFile .= ' '.var_export($class, true).' => $baseDir . '.var_export($path, true).",\n"; $classmapFile .= ' '.var_export($class, true).' => $baseDir . '.var_export($path, true).",\n";
} }
} }