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

Breadcrumb

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

function PathDownloader::download

@inheritDoc

Overrides FileDownloader::download

File

vendor/composer/composer/src/Composer/Downloader/PathDownloader.php, line 42

Class

PathDownloader
Download a package from a local path.

Namespace

Composer\Downloader

Code

public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true) : PromiseInterface {
    $path = Filesystem::trimTrailingSlash($path);
    $url = $package->getDistUrl();
    if (null === $url) {
        throw new \RuntimeException('The package ' . $package->getPrettyName() . ' has no dist url configured, cannot download.');
    }
    $realUrl = realpath($url);
    if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
        throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
    }
    if (realpath($path) === $realUrl) {
        return \React\Promise\resolve(null);
    }
    if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
        // IMPORTANT NOTICE: If you wish to change this, don't. You are wasting your time and ours.
        //
        // Please see https://github.com/composer/composer/pull/5974 and https://github.com/composer/composer/pull/6174
        // for previous attempts that were shut down because they did not work well enough or introduced too many risks.
        throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
    }
    return \React\Promise\resolve(null);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal