1
0
Fork 0

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

pull/5238/head
Jordi Boggiano 2016-04-22 20:30:24 +01:00
parent b6680b6f2a
commit aeafe2fe59
4 changed files with 26 additions and 7 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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
*

View File

@ -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