You are here

protected function OperationFactory::getPackagePath in Drupal 9

Same name and namespace in other branches
  1. 8 composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::getPackagePath()

Gets the file path of a package.

Note that if we call getInstallPath on the root package, we get the wrong answer (the installation manager thinks our package is in vendor). We therefore add special checking for this case.

Parameters

\Composer\Package\PackageInterface $package: The package.

Return value

string The file path.

2 calls to OperationFactory::getPackagePath()
OperationFactory::createAppendOp in composer/Plugin/Scaffold/Operations/OperationFactory.php
Creates an 'append' (or 'prepend') scaffold op.
OperationFactory::createReplaceOp in composer/Plugin/Scaffold/Operations/OperationFactory.php
Creates a 'replace' scaffold op.

File

composer/Plugin/Scaffold/Operations/OperationFactory.php, line 151

Class

OperationFactory
Create Scaffold operation objects based on provided metadata.

Namespace

Drupal\Composer\Plugin\Scaffold\Operations

Code

protected function getPackagePath(PackageInterface $package) {
  if ($package
    ->getName() == $this->composer
    ->getPackage()
    ->getName()) {

    // This will respect the --working-dir option if Composer is invoked with
    // it. There is no API or method to determine the filesystem path of
    // a package's composer.json file.
    return getcwd();
  }
  return $this->composer
    ->getInstallationManager()
    ->getInstallPath($package);
}