You are here

public function BaseInstaller::getInstallPath in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/composer/installers/src/Composer/Installers/BaseInstaller.php \Composer\Installers\BaseInstaller::getInstallPath()

Return the install path based on package type.

Parameters

PackageInterface $package:

string $frameworkType:

Return value

string

1 call to BaseInstaller::getInstallPath()
SilverStripeInstaller::getInstallPath in vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php
Return the install path based on package type.
1 method overrides BaseInstaller::getInstallPath()
SilverStripeInstaller::getInstallPath in vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php
Return the install path based on package type.

File

vendor/composer/installers/src/Composer/Installers/BaseInstaller.php, line 32

Class

BaseInstaller

Namespace

Composer\Installers

Code

public function getInstallPath(PackageInterface $package, $frameworkType = '') {
  $type = $this->package
    ->getType();
  $prettyName = $this->package
    ->getPrettyName();
  if (strpos($prettyName, '/') !== false) {
    list($vendor, $name) = explode('/', $prettyName);
  }
  else {
    $vendor = '';
    $name = $prettyName;
  }
  $availableVars = $this
    ->inflectPackageVars(compact('name', 'vendor', 'type'));
  $extra = $package
    ->getExtra();
  if (!empty($extra['installer-name'])) {
    $availableVars['name'] = $extra['installer-name'];
  }
  if ($this->composer
    ->getPackage()) {
    $extra = $this->composer
      ->getPackage()
      ->getExtra();
    if (!empty($extra['installer-paths'])) {
      $customPath = $this
        ->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
      if ($customPath !== false) {
        return $this
          ->templatePath($customPath, $availableVars);
      }
    }
  }
  $packageType = substr($type, strlen($frameworkType) + 1);
  $locations = $this
    ->getLocations();
  if (!isset($locations[$packageType])) {
    throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
  }
  return $this
    ->templatePath($locations[$packageType], $availableVars);
}