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

Breadcrumb

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

function JsonConfigSource::addRepository

@inheritDoc

Overrides ConfigSourceInterface::addRepository

File

vendor/composer/composer/src/Composer/Config/JsonConfigSource.php, line 60

Class

JsonConfigSource
JSON Configuration Source

Namespace

Composer\Config

Code

public function addRepository(string $name, $config, bool $append = true) : void {
    $this->manipulateJson('addRepository', static function (&$config, $repo, $repoConfig) use ($append) : void {
        // if converting from an array format to hashmap format, and there is a {"packagist.org":false} repo, we have
        // to convert it to "packagist.org": false key on the hashmap otherwise it fails schema validation
        if (isset($config['repositories'])) {
            foreach ($config['repositories'] as $index => $val) {
                if ($index === $repo) {
                    continue;
                }
                if (is_numeric($index) && ($val === [
                    'packagist' => false,
                ] || $val === [
                    'packagist.org' => false,
                ])) {
                    unset($config['repositories'][$index]);
                    $config['repositories']['packagist.org'] = false;
                    break;
                }
            }
        }
        if ($append) {
            $config['repositories'][$repo] = $repoConfig;
        }
        else {
            $config['repositories'] = [
                $repo => $repoConfig,
            ] + $config['repositories'];
        }
    }, $name, $config, $append);
}

API Navigation

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