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

Breadcrumb

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

function Transaction::getRootPackages

Determine which packages in the result are not required by any other packages in it.

These serve as a starting point to enumerate packages in a topological order despite potential cycles. If there are packages with a cycle on the top level the package with the lowest name gets picked

Return value

array<string, PackageInterface>

1 call to Transaction::getRootPackages()
Transaction::calculateOperations in vendor/composer/composer/src/Composer/DependencyResolver/Transaction.php

File

vendor/composer/composer/src/Composer/DependencyResolver/Transaction.php, line 220

Class

Transaction
@author Nils Adermann <naderman@naderman.de> @internal

Namespace

Composer\DependencyResolver

Code

protected function getRootPackages() : array {
    $roots = $this->resultPackageMap;
    foreach ($this->resultPackageMap as $packageHash => $package) {
        if (!isset($roots[$packageHash])) {
            continue;
        }
        foreach ($package->getRequires() as $link) {
            $possibleRequires = $this->getProvidersInResult($link);
            foreach ($possibleRequires as $require) {
                if ($require !== $package) {
                    unset($roots[spl_object_hash($require)]);
                }
            }
        }
    }
    return $roots;
}

API Navigation

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