You are here

protected function AllowedPackages::recursiveGetAllowedPackages in Drupal 9

Same name and namespace in other branches
  1. 8 composer/Plugin/Scaffold/AllowedPackages.php \Drupal\Composer\Plugin\Scaffold\AllowedPackages::recursiveGetAllowedPackages()

Builds a name-to-package mapping from a list of package names.

Parameters

string[] $packages_to_allow: List of package names to allow.

array $allowed_packages: Mapping of package names to PackageInterface of packages already accumulated.

Return value

\Composer\Package\PackageInterface[] Mapping of package names to PackageInterface in priority order.

1 call to AllowedPackages::recursiveGetAllowedPackages()
AllowedPackages::getAllowedPackages in composer/Plugin/Scaffold/AllowedPackages.php
Gets a list of all packages that are allowed to copy scaffold files.

File

composer/Plugin/Scaffold/AllowedPackages.php, line 143

Class

AllowedPackages
Determine recursively which packages have been allowed to scaffold files.

Namespace

Drupal\Composer\Plugin\Scaffold

Code

protected function recursiveGetAllowedPackages(array $packages_to_allow, array $allowed_packages = []) {
  foreach ($packages_to_allow as $name) {
    $package = $this
      ->getPackage($name);
    if ($package instanceof PackageInterface && !isset($allowed_packages[$name])) {
      $allowed_packages[$name] = $package;
      $package_options = $this->manageOptions
        ->packageOptions($package);
      $allowed_packages = $this
        ->recursiveGetAllowedPackages($package_options
        ->allowedPackages(), $allowed_packages);
    }
  }
  return $allowed_packages;
}