Add INIT event and bump plugin-api to 1.1.0, fixes #5232

main
Jordi Boggiano 8 years ago
parent b6680b6f2a
commit aeafe2fe59

@ -54,6 +54,7 @@ Composer fires the following named events during its execution process:
### Plugin Events
- **init**: occurs after a Composer instance is done being initialized.
- **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.
- **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)
- Package Events: [`Composer\Installer\PackageEvent`](https://getcomposer.org/apidoc/master/Composer/Installer/PackageEvent.html)
- 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)
- 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\RemoteFilesystem;
use Composer\Util\Silencer;
use Composer\Plugin\PluginEvents;
use Composer\EventDispatcher\Event;
use Seld\JsonLint\DuplicateKeyException;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Composer\EventDispatcher\EventDispatcher;
@ -353,12 +355,6 @@ class Factory
$composer->setPluginManager($pm);
$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
@ -371,6 +367,17 @@ class Factory
$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;
}

@ -19,6 +19,16 @@ namespace Composer\Plugin;
*/
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
*

@ -27,7 +27,7 @@ interface PluginInterface
*
* @var string
*/
const PLUGIN_API_VERSION = '1.0.0';
const PLUGIN_API_VERSION = '1.1.0';
/**
* Apply plugin modifications to Composer

Loading…
Cancel
Save