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

Breadcrumb

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

function GitBitbucketDriver::getComposerInformation

@inheritDoc

Overrides VcsDriver::getComposerInformation

File

vendor/composer/composer/src/Composer/Repository/Vcs/GitBitbucketDriver.php, line 137

Class

GitBitbucketDriver
@author Per Bernhardt <plb@webfactory.de>

Namespace

Composer\Repository\Vcs

Code

public function getComposerInformation(string $identifier) : ?array {
    if ($this->fallbackDriver) {
        return $this->fallbackDriver
            ->getComposerInformation($identifier);
    }
    if (!isset($this->infoCache[$identifier])) {
        if ($this->shouldCache($identifier) && ($res = $this->cache
            ->read($identifier))) {
            $composer = JsonFile::parseJson($res);
        }
        else {
            $composer = $this->getBaseComposerInformation($identifier);
            if ($this->shouldCache($identifier)) {
                $this->cache
                    ->write($identifier, json_encode($composer));
            }
        }
        if ($composer !== null) {
            // specials for bitbucket
            if (isset($composer['support']) && !is_array($composer['support'])) {
                $composer['support'] = [];
            }
            if (!isset($composer['support']['source'])) {
                $label = (array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches())) ?: $identifier;
                if (array_key_exists($label, $tags = $this->getTags())) {
                    $hash = $tags[$label];
                }
                elseif (array_key_exists($label, $branches = $this->getBranches())) {
                    $hash = $branches[$label];
                }
                if (!isset($hash)) {
                    $composer['support']['source'] = sprintf('https://%s/%s/%s/src', $this->originUrl, $this->owner, $this->repository);
                }
                else {
                    $composer['support']['source'] = sprintf('https://%s/%s/%s/src/%s/?at=%s', $this->originUrl, $this->owner, $this->repository, $hash, $label);
                }
            }
            if (!isset($composer['support']['issues']) && $this->hasIssues) {
                $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
            }
            if (!isset($composer['homepage'])) {
                $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
            }
        }
        $this->infoCache[$identifier] = $composer;
    }
    return $this->infoCache[$identifier];
}
RSS feed
Powered by Drupal