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

Breadcrumb

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

function DownloadManager::getAvailableSources

@phpstan-return array<'dist'|'source'>&non-empty-array

Return value

string[]

1 call to DownloadManager::getAvailableSources()
DownloadManager::download in vendor/composer/composer/src/Composer/Downloader/DownloadManager.php
Downloads package into target dir.

File

vendor/composer/composer/src/Composer/Downloader/DownloadManager.php, line 393

Class

DownloadManager
Downloaders manager.

Namespace

Composer\Downloader

Code

private function getAvailableSources(PackageInterface $package, ?PackageInterface $prevPackage = null) : array {
    $sourceType = $package->getSourceType();
    $distType = $package->getDistType();
    // add source before dist by default
    $sources = [];
    if ($sourceType) {
        $sources[] = 'source';
    }
    if ($distType) {
        $sources[] = 'dist';
    }
    if (empty($sources)) {
        throw new \InvalidArgumentException('Package ' . $package . ' must have a source or dist specified');
    }
    if ($prevPackage && in_array($prevPackage->getInstallationSource(), $sources, true) && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())) {
        $prevSource = $prevPackage->getInstallationSource();
        usort($sources, static function ($a, $b) use ($prevSource) : int {
            return $a === $prevSource ? -1 : 1;
        });
        return $sources;
    }
    // reverse sources in case dist is the preferred source for this package
    if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
        $sources = array_reverse($sources);
    }
    return $sources;
}

API Navigation

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