You are here

protected function ExtraPackage::addRepositories in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php \Wikimedia\Composer\Merge\ExtraPackage::addRepositories()

Add a collection of repositories described by the given configuration to the given package and the global repository manager.

Parameters

RootPackageInterface $root:

1 call to ExtraPackage::addRepositories()
ExtraPackage::mergeInto in vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php
Merge this package into a RootPackageInterface

File

vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php, line 175

Class

ExtraPackage
Processing for a composer.json file that will be merged into a RootPackageInterface

Namespace

Wikimedia\Composer\Merge

Code

protected function addRepositories(RootPackageInterface $root) {
  if (!isset($this->json['repositories'])) {
    return;
  }
  $repoManager = $this->composer
    ->getRepositoryManager();
  $newRepos = array();
  foreach ($this->json['repositories'] as $repoJson) {
    if (!isset($repoJson['type'])) {
      continue;
    }
    $this->logger
      ->info("Adding {$repoJson['type']} repository");
    $repo = $repoManager
      ->createRepository($repoJson['type'], $repoJson);
    $repoManager
      ->addRepository($repo);
    $newRepos[] = $repo;
  }
  $unwrapped = self::unwrapIfNeeded($root, 'setRepositories');
  $unwrapped
    ->setRepositories(array_merge($newRepos, $root
    ->getRepositories()));
}