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

Breadcrumb

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

function PluginManager::loadRepository

Load all plugins and installers from a repository

If a plugin requires another plugin, the required one will be loaded first

Note that plugins in the specified repository that rely on events that have fired prior to loading will be missed. This means you likely want to call this method as early as possible.

@phpstan-param ($isGlobalRepo is true ? null : RootPackageInterface) $rootPackage

Parameters

RepositoryInterface $repo Repository to scan for plugins to install:

Throws

\RuntimeException

1 call to PluginManager::loadRepository()
PluginManager::loadInstalledPlugins in vendor/composer/composer/src/Composer/Plugin/PluginManager.php
Loads all plugins from currently installed plugin packages

File

vendor/composer/composer/src/Composer/Plugin/PluginManager.php, line 454

Class

PluginManager
Plugin manager

Namespace

Composer\Plugin

Code

private function loadRepository(RepositoryInterface $repo, bool $isGlobalRepo, ?RootPackageInterface $rootPackage = null) : void {
    $packages = $repo->getPackages();
    $weights = [];
    foreach ($packages as $package) {
        if ($package->getType() === 'composer-plugin') {
            $extra = $package->getExtra();
            if ($package->getName() === 'composer/installers' || true === ($extra['plugin-modifies-install-path'] ?? false)) {
                $weights[$package->getName()] = -10000;
            }
        }
    }
    $sortedPackages = PackageSorter::sortPackages($packages, $weights);
    if (!$isGlobalRepo) {
        $requiredPackages = RepositoryUtils::filterRequiredPackages($packages, $rootPackage, true);
    }
    foreach ($sortedPackages as $package) {
        if (!$package instanceof CompletePackage) {
            continue;
        }
        if (!in_array($package->getType(), [
            'composer-plugin',
            'composer-installer',
        ], true)) {
            continue;
        }
        if (!$isGlobalRepo && !in_array($package, $requiredPackages, true) && !$this->isPluginAllowed($package->getName(), false, true, false)) {
            $this->io
                ->writeError('<warning>The "' . $package->getName() . '" plugin was not loaded as it is not listed in allow-plugins and is not required by the root package anymore.</warning>');
            continue;
        }
        if ('composer-plugin' === $package->getType()) {
            $this->registerPackage($package, false, $isGlobalRepo);
            // Backward compatibility
        }
        elseif ('composer-installer' === $package->getType()) {
            $this->registerPackage($package, false, $isGlobalRepo);
        }
    }
}
RSS feed
Powered by Drupal