function Unpacker::processPackageDependencies

Processes dependencies of the package that is being unpacked.

If the dependency is a recipe and should be unpacked, we add it into the package queue so that it will be unpacked as well. If the dependency is not a recipe, or an ignored recipe, the package link will be yielded.

Parameters

array<string, \Composer\Package\Link> $package_dependency_links: The package dependencies to process.

Return value

iterable<\Composer\Package\Link> The package dependencies to add to composer.json.

1 call to Unpacker::processPackageDependencies()
Unpacker::updateComposerJsonPackages in composer/Plugin/RecipeUnpack/Unpacker.php
Updates the composer.json content with the package being unpacked.

File

composer/Plugin/RecipeUnpack/Unpacker.php, line 56

Class

Unpacker
Handles the details of unpacking a specific recipe.

Namespace

Drupal\Composer\Plugin\RecipeUnpack

Code

private function processPackageDependencies(array $package_dependency_links) : iterable {
    foreach ($package_dependency_links as $link) {
        if ($link->getTarget() === $this->package
            ->getName()) {
            // This dependency is the same as the current package, so let's skip it.
            continue;
        }
        $package = $this->getPackageFromLinkTarget($link);
        // If we can't find the package in the local repository that's because it
        // has already been removed therefore skip it.
        if ($package === NULL) {
            continue;
        }
        if ($package->getType() === Plugin::RECIPE_PACKAGE_TYPE) {
            if ($this->unpackCollection
                ->isUnpacked($package)) {
                // This dependency is already unpacked.
                continue;
            }
            if (!$this->unpackOptions
                ->isIgnored($package)) {
                // This recipe should be unpacked as well.
                $this->unpackCollection
                    ->add($package);
                continue;
            }
            else {
                // This recipe should not be unpacked. But it might need to be added
                // to the root composer.json
                $this->io
                    ->write(sprintf('<info>%s</info> not unpacked because it is ignored.', $package->getName()), verbosity: IOInterface::VERBOSE);
            }
        }
        (yield $link);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.