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

Breadcrumb

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

function GitLabDriver::getComposerInformation

@inheritDoc

Overrides VcsDriver::getComposerInformation

File

vendor/composer/composer/src/Composer/Repository/Vcs/GitLabDriver.php, line 149

Class

GitLabDriver
Driver for GitLab API, use the Git driver for local checkouts.

Namespace

Composer\Repository\Vcs

Code

public function getComposerInformation(string $identifier) : ?array {
    if ($this->gitDriver) {
        return $this->gitDriver
            ->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 (null !== $composer) {
            // specials for gitlab (this data is only available if authentication is provided)
            if (isset($composer['support']) && !is_array($composer['support'])) {
                $composer['support'] = [];
            }
            if (!isset($composer['support']['source']) && isset($this->project['web_url'])) {
                $label = (array_search($identifier, $this->getTags(), true) ?: array_search($identifier, $this->getBranches(), true)) ?: $identifier;
                $composer['support']['source'] = sprintf('%s/-/tree/%s', $this->project['web_url'], $label);
            }
            if (!isset($composer['support']['issues']) && !empty($this->project['issues_enabled']) && isset($this->project['web_url'])) {
                $composer['support']['issues'] = sprintf('%s/-/issues', $this->project['web_url']);
            }
            if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
                $composer['abandoned'] = true;
            }
        }
        $this->infoCache[$identifier] = $composer;
    }
    return $this->infoCache[$identifier];
}
RSS feed
Powered by Drupal