src/Composer/Plugin/PluginManager.php
public function loadRepository(RepositoryInterface $repo)
    {
        foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */
            if ($package instanceof AliasPackage) {
                continue;
            }
            if ('composer-plugin' === $package->getType()) {
                $requiresComposer = null;
                foreach ($package->getRequires() as $link) { /** @var Link $link */
                    if ('composer-plugin-api' === $link->getTarget()) {
                        $requiresComposer = $link->getConstraint();
                        break;
                    }
                }

                if (!$requiresComposer) {
                    throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
                }

                $currentPluginApiVersion = $this->getPluginApiVersion();
                $currentPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currentPluginApiVersion));

                if (!$requiresComposer->matches($currentPluginApiConstraint)) {
                    $this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
                    continue;
                }

                $this->registerPackage($package);

            // Backward compatibility
            } elseif ('composer-installer' === $package->getType()) {
                $this->registerPackage($package);
            }
        }
    }
public function loadRepository(RepositoryInterface $repo)
    {
        foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */
            if ($package instanceof AliasPackage) {
                continue;
            }
            if ('composer-plugin' === $package->getType()) {
                $requiresComposer = null;
                foreach ($package->getRequires() as $link) { /** @var Link $link */
                    if ('composer-plugin-api' === $link->getTarget()) {
                        $requiresComposer = $link->getConstraint();
                        break;
                    }
                }

                if (!$requiresComposer) {
                    throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
                }

                $currentPluginApiVersion = $this->getPluginApiVersion();
                $currentPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currentPluginApiVersion));

                if (!$requiresComposer->matches($currentPluginApiConstraint)) {
                    $this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
                    continue;
                }

                $this->registerPackage($package);

            // Backward compatibility
            } elseif ('composer-installer' === $package->getType()) {
                $this->registerPackage($package);
            }
        }
    }
public function loadRepository ( RepositoryInterface $ repo ) { foreach ( $ repo -> getPackages ( ) as $ package ) { /** @var PackageInterface $package */ if ( $ package instanceof AliasPackage ) { continue ; } if ( 'composer-plugin' === $ package -> getType ( ) ) { $ requiresComposer = null ; foreach ( $ package -> getRequires ( ) as $ link ) { /** @var Link $link */ if ( 'composer-plugin-api' === $ link -> getTarget ( ) ) { $ requiresComposer = $ link -> getConstraint ( ) ; break ; } } if ( ! $ requiresComposer ) { throw new \ RuntimeException ( "Plugin " . $ package -> getName ( ) . " is missing a require statement for a version of the composer-plugin-api package." ) ; } $ currentPluginApiVersion = $ this -> getPluginApiVersion ( ) ; $ currentPluginApiConstraint = new VersionConstraint ( '==' , $ this -> versionParser -> normalize ( $ currentPluginApiVersion ) ) ; if ( ! $ requiresComposer -> matches ( $ currentPluginApiConstraint ) ) { $ this -> io -> writeError ( '<warning>The "' . $ package -> getName ( ) . '" plugin was skipped because it requires a Plugin API version ("' . $ requiresComposer -> getPrettyString ( ) . '") that does not match your Composer installation ("' . $ currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>' ) ; continue ; } $ this -> registerPackage ( $ package ) ; // Backward compatibility } elseif ( 'composer-installer' === $ package -> getType ( ) ) { $ this -> registerPackage ( $ package ) ; } } }
Load all plugins and installers from a repository

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.

@param RepositoryInterface $repo Repository to scan for plugins to install

@throws \RuntimeException
Load all plugins and installers from a repository