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

Breadcrumb

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

function VcsRepository::getCachedPackageVersion

Return value

\Composer\Package\CompletePackage|\Composer\Package\CompleteAliasPackage|null|false null if no cache present, false if the absence of a version was cached

1 call to VcsRepository::getCachedPackageVersion()
VcsRepository::initialize in vendor/composer/composer/src/Composer/Repository/VcsRepository.php
Initializes the packages array. Mostly meant as an extension point.

File

vendor/composer/composer/src/Composer/Repository/VcsRepository.php, line 483

Class

VcsRepository
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Repository

Code

private function getCachedPackageVersion(string $version, string $identifier, bool $isVerbose, bool $isVeryVerbose, bool $isDefaultBranch = false) {
    if (!$this->versionCache) {
        return null;
    }
    $cachedPackage = $this->versionCache
        ->getVersionPackage($version, $identifier);
    if ($cachedPackage === false) {
        if ($isVeryVerbose) {
            $this->io
                ->writeError('<warning>Skipped ' . $version . ', no composer file (cached from ref ' . $identifier . ')</warning>');
        }
        return false;
    }
    if ($cachedPackage) {
        $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
        if ($isVeryVerbose) {
            $this->io
                ->writeError($msg);
        }
        elseif ($isVerbose) {
            $this->io
                ->overwriteError($msg, false);
        }
        unset($cachedPackage['default-branch']);
        if ($isDefaultBranch) {
            $cachedPackage['default-branch'] = true;
        }
        if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
            if ($isVeryVerbose) {
                $this->io
                    ->writeError('<warning>Skipped cached version ' . $version . ', it conflicts with an another tag (' . $existingPackage->getPrettyVersion() . ') as both resolve to ' . $cachedPackage['version_normalized'] . ' internally</warning>');
            }
            $cachedPackage = null;
        }
    }
    if ($cachedPackage) {
        return $this->loader
            ->load($cachedPackage);
    }
    return null;
}
RSS feed
Powered by Drupal