function OperationFactory::getPackagePath

Same name in other branches
  1. 9 composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::getPackagePath()
  2. 8.9.x composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::getPackagePath()
  3. 11.x 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 152

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.