diff --git a/composer.json b/composer.json index f8c17ec..e6e177e 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "license": "MIT", "minimum-stability": "stable", "require": { - "composer-plugin-api": "^1.0" + "composer-plugin-api": "^1.0 || ^2.0" }, "autoload": { "psr-4": { diff --git a/src/Plugin.php b/src/Plugin.php index ed96535..c672279 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -17,18 +17,38 @@ */ class Plugin implements PluginInterface { + /** + * @var Installer + */ + private $installer; + /** * @inheritdoc */ public function activate(Composer $composer, IOInterface $io) { // Register the plugin installer - $installer = new Installer($io, $composer, 'craft-plugin'); - $composer->getInstallationManager()->addInstaller($installer); + $this->installer = new Installer($io, $composer, 'craft-plugin'); + $composer->getInstallationManager()->addInstaller($this->installer); // Is this a plugin at root? Elementary, my dear Watson 🕵️! - if ($installer->supports($composer->getPackage()->getType())) { - $installer->addPlugin($composer->getPackage(), true); + if ($this->installer->supports($composer->getPackage()->getType())) { + $this->installer->addPlugin($composer->getPackage(), true); } } + + /** + * @inheritdoc + */ + public function deactivate(Composer $composer, IOInterface $io) + { + $composer->getInstallationManager()->removeInstaller($this->installer); + } + + /** + * @inheritdoc + */ + public function uninstall(Composer $composer, IOInterface $io) + { + } }