Browse Source

[Autoload] Set $vendorDir et $baseDir in ComposerAutoloaderInitTargetDir::getLoader()

Victor Berchet 12 years ago
parent
commit
d2dc73e361

+ 4 - 2
src/Composer/Autoload/AutoloadGenerator.php

@@ -137,7 +137,7 @@ EOF;
             file_put_contents($targetDir.'/include_paths.php', $includePathFile);
         }
         file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
-        file_put_contents($targetDir.'/autoload_real'.$suffix.'.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $suffix));
+        file_put_contents($targetDir.'/autoload_real'.$suffix.'.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix));
         copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
     }
 
@@ -295,7 +295,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
 AUTOLOAD;
     }
 
-    protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $suffix)
+    protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix)
     {
         // TODO the class ComposerAutoloaderInit should be revert to a closure
         // when APC has been fixed:
@@ -321,6 +321,8 @@ class ComposerAutoloaderInit$suffix
     public static function getLoader()
     {
         \$loader = new \\Composer\\Autoload\\ClassLoader();
+        \$vendorDir = $vendorPathCode;
+        \$baseDir = $appBaseDirCode;
 
 
 HEADER;

+ 2 - 0
tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php

@@ -10,6 +10,8 @@ class ComposerAutoloaderInitFilesAutoload
     public static function getLoader()
     {
         $loader = new \Composer\Autoload\ClassLoader();
+        $vendorDir = dirname(__DIR__);
+        $baseDir = dirname($vendorDir);
 
         $map = require __DIR__ . '/autoload_namespaces.php';
         foreach ($map as $namespace => $path) {

+ 2 - 0
tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php

@@ -10,6 +10,8 @@ class ComposerAutoloaderInitTargetDir
     public static function getLoader()
     {
         $loader = new \Composer\Autoload\ClassLoader();
+        $vendorDir = dirname(__DIR__);
+        $baseDir = dirname($vendorDir);
 
         $map = require __DIR__ . '/autoload_namespaces.php';
         foreach ($map as $namespace => $path) {