Add INIT event and bump plugin-api to 1.1.0, fixes #5232
parent
b6680b6f2a
commit
aeafe2fe59
|
@ -54,6 +54,7 @@ Composer fires the following named events during its execution process:
|
||||||
|
|
||||||
### Plugin Events
|
### Plugin Events
|
||||||
|
|
||||||
|
- **init**: occurs after a Composer instance is done being initialized.
|
||||||
- **command**: occurs before any Composer Command is executed on the CLI. It
|
- **command**: occurs before any Composer Command is executed on the CLI. It
|
||||||
provides you with access to the input and output objects of the program.
|
provides you with access to the input and output objects of the program.
|
||||||
- **pre-file-download**: occurs before files are downloaded and allows
|
- **pre-file-download**: occurs before files are downloaded and allows
|
||||||
|
@ -162,6 +163,7 @@ objects:
|
||||||
- Installer Events: [`Composer\Installer\InstallerEvent`](https://getcomposer.org/apidoc/master/Composer/Installer/InstallerEvent.html)
|
- Installer Events: [`Composer\Installer\InstallerEvent`](https://getcomposer.org/apidoc/master/Composer/Installer/InstallerEvent.html)
|
||||||
- Package Events: [`Composer\Installer\PackageEvent`](https://getcomposer.org/apidoc/master/Composer/Installer/PackageEvent.html)
|
- Package Events: [`Composer\Installer\PackageEvent`](https://getcomposer.org/apidoc/master/Composer/Installer/PackageEvent.html)
|
||||||
- Plugin Events:
|
- Plugin Events:
|
||||||
|
- init: [`Composer\EventDispatcher\Event`](https://getcomposer.org/apidoc/master/Composer/EventDispatcher/Event.html)
|
||||||
- command: [`Composer\Plugin\CommandEvent`](https://getcomposer.org/apidoc/master/Composer/Plugin/CommandEvent.html)
|
- command: [`Composer\Plugin\CommandEvent`](https://getcomposer.org/apidoc/master/Composer/Plugin/CommandEvent.html)
|
||||||
- pre-file-download: [`Composer\Plugin\PreFileDownloadEvent`](https://getcomposer.org/apidoc/master/Composer/Plugin/PreFileDownloadEvent.html)
|
- pre-file-download: [`Composer\Plugin\PreFileDownloadEvent`](https://getcomposer.org/apidoc/master/Composer/Plugin/PreFileDownloadEvent.html)
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ use Composer\Util\Platform;
|
||||||
use Composer\Util\ProcessExecutor;
|
use Composer\Util\ProcessExecutor;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
use Composer\Util\Silencer;
|
use Composer\Util\Silencer;
|
||||||
|
use Composer\Plugin\PluginEvents;
|
||||||
|
use Composer\EventDispatcher\Event;
|
||||||
use Seld\JsonLint\DuplicateKeyException;
|
use Seld\JsonLint\DuplicateKeyException;
|
||||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||||
use Composer\EventDispatcher\EventDispatcher;
|
use Composer\EventDispatcher\EventDispatcher;
|
||||||
|
@ -353,12 +355,6 @@ class Factory
|
||||||
$composer->setPluginManager($pm);
|
$composer->setPluginManager($pm);
|
||||||
|
|
||||||
$pm->loadInstalledPlugins();
|
$pm->loadInstalledPlugins();
|
||||||
|
|
||||||
// once we have plugins and custom installers we can
|
|
||||||
// purge packages from local repos if they have been deleted on the filesystem
|
|
||||||
if ($rm->getLocalRepository()) {
|
|
||||||
$this->purgePackages($rm->getLocalRepository(), $im);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// init locker if possible
|
// init locker if possible
|
||||||
|
@ -371,6 +367,17 @@ class Factory
|
||||||
$composer->setLocker($locker);
|
$composer->setLocker($locker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($fullLoad) {
|
||||||
|
$initEvent = new Event(PluginEvents::INIT);
|
||||||
|
$composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
|
||||||
|
|
||||||
|
// once everything is initialized we can
|
||||||
|
// purge packages from local repos if they have been deleted on the filesystem
|
||||||
|
if ($rm->getLocalRepository()) {
|
||||||
|
$this->purgePackages($rm->getLocalRepository(), $im);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $composer;
|
return $composer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,16 @@ namespace Composer\Plugin;
|
||||||
*/
|
*/
|
||||||
class PluginEvents
|
class PluginEvents
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The INIT event occurs after a Composer instance is done being initialized
|
||||||
|
*
|
||||||
|
* The event listener method receives a
|
||||||
|
* Composer\EventDispatcher\Event instance.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const INIT = 'init';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The COMMAND event occurs as a command begins
|
* The COMMAND event occurs as a command begins
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,7 +27,7 @@ interface PluginInterface
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const PLUGIN_API_VERSION = '1.0.0';
|
const PLUGIN_API_VERSION = '1.1.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply plugin modifications to Composer
|
* Apply plugin modifications to Composer
|
||||||
|
|
Loading…
Reference in New Issue