mirror of
https://github.com/composer/composer
synced 2025-05-11 01:22:54 +00:00
Load plugins from global vendor dir too
This commit is contained in:
parent
5867d477be
commit
c5c180fdd2
2 changed files with 43 additions and 9 deletions
|
@ -14,8 +14,9 @@ namespace Composer\Plugin;
|
|||
|
||||
use Composer\Composer;
|
||||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\Package\Package;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\Package;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\Link;
|
||||
use Composer\DependencyResolver\Pool;
|
||||
|
@ -29,6 +30,7 @@ class PluginManager
|
|||
{
|
||||
protected $composer;
|
||||
protected $io;
|
||||
protected $globalRepository;
|
||||
|
||||
protected $plugins = array();
|
||||
|
||||
|
@ -39,10 +41,11 @@ class PluginManager
|
|||
*
|
||||
* @param Composer $composer
|
||||
*/
|
||||
public function __construct(Composer $composer, IOInterface $io)
|
||||
public function __construct(Composer $composer, IOInterface $io, RepositoryInterface $globalRepository = null)
|
||||
{
|
||||
$this->composer = $composer;
|
||||
$this->io = $io;
|
||||
$this->globalRepository = $globalRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,11 +56,10 @@ class PluginManager
|
|||
$repo = $this->composer->getRepositoryManager()->getLocalRepository();
|
||||
|
||||
if ($repo) {
|
||||
foreach ($repo->getPackages() as $package) {
|
||||
if ('composer-plugin' === $package->getType() || 'composer-installer' === $package->getType()) {
|
||||
$this->registerPackage($package);
|
||||
}
|
||||
}
|
||||
$this->loadRepository($repo);
|
||||
}
|
||||
if ($this->globalRepository) {
|
||||
$this->loadRepository($this->globalRepository);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +88,15 @@ class PluginManager
|
|||
return $this->plugins;
|
||||
}
|
||||
|
||||
protected function loadRepository(RepositoryInterface $repo)
|
||||
{
|
||||
foreach ($repo->getPackages() as $package) {
|
||||
if ('composer-plugin' === $package->getType() || 'composer-installer' === $package->getType()) {
|
||||
$this->registerPackage($package);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively generates a map of package names to packages for all deps
|
||||
*
|
||||
|
@ -150,6 +161,9 @@ class PluginManager
|
|||
|
||||
$pool = new Pool('dev');
|
||||
$pool->addRepository($this->composer->getRepositoryManager()->getLocalRepository());
|
||||
if ($this->globalRepository) {
|
||||
$pool->addRepository($this->globalRepository);
|
||||
}
|
||||
|
||||
$autoloadPackages = array($package->getName() => $package);
|
||||
$autoloadPackages = $this->collectDependencies($pool, $autoloadPackages, $package);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue