Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. OperationFactory.php

function 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);
}
RSS feed
Powered by Drupal