Created
May 30, 2015 16:24
-
-
Save nevvermind/4932a246079f59cea5a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function loadRepository(RepositoryInterface $repo) | |
{ | |
foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */ | |
if ($package instanceof AliasPackage) { | |
continue; | |
} | |
switch ($package->getType()) { | |
case 'composer-plugin': | |
$requiresComposer = null; | |
foreach ($package->getRequires() as $link) { /** @var Link $link */ | |
if ($link->getTarget() == 'composer-plugin-api') { | |
$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."); | |
} | |
// if the required Plugin API version is exactly "1.0.0", convert it to "^1.0", to keep BC | |
if ($requiresComposer->matches(new VersionConstraint('==', $this->versionParser->normalize('1.0.0')))) { | |
$requiresComposer = $this->versionParser->parseConstraints('^1.0'); | |
} | |
$currComposerPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize(PluginInterface::PLUGIN_API_VERSION)); | |
if (!$requiresComposer->matches($currComposerPluginApiConstraint)) { | |
$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 ("'.PluginInterface::PLUGIN_API_VERSION.'"). You may need to run composer update with the "--no-plugins" option.</warning>'); | |
continue 2; | |
} | |
$this->registerPackage($package); | |
break; | |
case 'composer-installer': // Backward compatibility | |
$this->registerPackage($package); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that incompatible (version mismatch) plugins are not registered anymore. (line 33)