1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-11 01:22:54 +00:00

Load plugins before purging packages, fixes #3557

This commit is contained in:
Jordi Boggiano 2014-12-15 20:34:23 +00:00
parent 0c87048fed
commit 2b16a73659
3 changed files with 13 additions and 9 deletions

View file

@ -190,10 +190,11 @@ class PluginManager
* instead for BC
*
* @param PackageInterface $package
* @param bool $failOnMissingClasses By default this silently skips plugins that can not be found, but if set to true it fails with an exception
*
* @throws \UnexpectedValueException
*/
public function registerPackage(PackageInterface $package)
public function registerPackage(PackageInterface $package, $failOnMissingClasses = false)
{
$oldInstallerPlugin = ($package->getType() === 'composer-installer');
@ -242,10 +243,12 @@ class PluginManager
if ($oldInstallerPlugin) {
$installer = new $class($this->io, $this->composer);
$this->composer->getInstallationManager()->addInstaller($installer);
} else {
} elseif (class_exists($class)) {
$plugin = new $class();
$this->addPlugin($plugin);
$this->registeredPlugins[] = $package->getName();
} elseif ($failOnMissingClasses) {
throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
}
}
}