1
0
Fork 0

fixes a bug when root package has a 'files' autoload entry

pull/942/head
Johannes M. Schmitt 2012-07-23 21:58:47 +02:00
parent ac29308eb7
commit 9f150b1c1e
2 changed files with 7 additions and 2 deletions

View File

@ -127,6 +127,10 @@ EOF;
$filesCode = "";
$autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files']));
foreach ($autoloads['files'] as $functionFile) {
if ( ! $filesystem->isAbsolutePath($functionFile)) {
$functionFile = dirname($vendorPath) . '/'. $functionFile;
}
$filesCode .= ' require __DIR__ . '. var_export('/'.$filesystem->findShortestPath($vendorPath, $functionFile), true).";\n";
}
@ -181,6 +185,7 @@ EOF;
if (!is_array($mapping)) {
continue;
}
foreach ($mapping as $namespace => $paths) {
foreach ((array) $paths as $path) {
$autoloads[$type][$namespace][] = empty($installPath) ? $path : $installPath.'/'.$path;

View File

@ -64,7 +64,7 @@ class Filesystem
public function findShortestPath($from, $to, $directories = false)
{
if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
throw new \InvalidArgumentException('from and to must be absolute paths');
throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
}
$from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
@ -105,7 +105,7 @@ class Filesystem
public function findShortestPathCode($from, $to, $directories = false)
{
if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
throw new \InvalidArgumentException('from and to must be absolute paths');
throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
}
$from = lcfirst(strtr($from, '\\', '/'));