|
|
@ -100,25 +100,42 @@ class Installer extends LibraryInstaller |
|
|
|
|
|
|
|
|
|
|
|
protected function generateDefaultAlias(PackageInterface $package) |
|
|
|
protected function generateDefaultAlias(PackageInterface $package) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$autoload = $package->getAutoload(); |
|
|
|
|
|
|
|
if (empty($autoload['psr-0'])) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$fs = new Filesystem; |
|
|
|
$fs = new Filesystem; |
|
|
|
$vendorDir = $fs->normalizePath($this->vendorDir); |
|
|
|
$vendorDir = $fs->normalizePath($this->vendorDir); |
|
|
|
|
|
|
|
$autoload = $package->getAutoload(); |
|
|
|
|
|
|
|
|
|
|
|
$aliases = []; |
|
|
|
$aliases = []; |
|
|
|
foreach ($autoload['psr-0'] as $name => $path) { |
|
|
|
|
|
|
|
$name = str_replace('\\', '/', trim($name, '\\')); |
|
|
|
if (!empty($autoload['psr-0'])) { |
|
|
|
if (!$fs->isAbsolutePath($path)) { |
|
|
|
foreach ($autoload['psr-0'] as $name => $path) { |
|
|
|
$path = $this->vendorDir . '/' . $package->getName() . '/' . $path; |
|
|
|
$name = str_replace('\\', '/', trim($name, '\\')); |
|
|
|
|
|
|
|
if (!$fs->isAbsolutePath($path)) { |
|
|
|
|
|
|
|
$path = $this->vendorDir . '/' . $package->getName() . '/' . $path; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$path = $fs->normalizePath($path); |
|
|
|
|
|
|
|
if (strpos($path . '/', $vendorDir . '/') === 0) { |
|
|
|
|
|
|
|
$aliases["@$name"] = '<vendor-dir>' . substr($path, strlen($vendorDir)) . '/' . $name; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$aliases["@$name"] = $path . '/' . $name; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$path = $fs->normalizePath($path); |
|
|
|
} |
|
|
|
if (strpos($path . '/', $vendorDir . '/') === 0) { |
|
|
|
|
|
|
|
$aliases["@$name"] = '<vendor-dir>' . substr($path, strlen($vendorDir)) . '/' . $name; |
|
|
|
if (!empty($autoload['psr-4'])) { |
|
|
|
} else { |
|
|
|
foreach ($autoload['psr-4'] as $name => $path) { |
|
|
|
$aliases["@$name"] = $path . '/' . $name; |
|
|
|
$name = str_replace('\\', '/', trim($name, '\\')); |
|
|
|
|
|
|
|
if (!$fs->isAbsolutePath($path)) { |
|
|
|
|
|
|
|
$path = $this->vendorDir . '/' . $package->getName() . '/' . $path; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$path = $fs->normalizePath($path); |
|
|
|
|
|
|
|
if (strpos($path . '/', $vendorDir . '/') === 0) { |
|
|
|
|
|
|
|
$aliases["@$name"] = '<vendor-dir>' . substr($path, strlen($vendorDir)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$aliases["@$name"] = $path; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $aliases; |
|
|
|
return $aliases; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|