diff --git a/composer.json b/composer.json index eecce2b..a9426c6 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,6 @@ "class": "Joomlatools\\Composer\\Plugin" }, "require": { - "composer-plugin-api": "^1.0" + "composer-plugin-api": "^2.0" } } diff --git a/src/Joomlatools/Composer/ExtensionInstaller.php b/src/Joomlatools/Composer/ExtensionInstaller.php index 2003e1c..004fc7f 100644 --- a/src/Joomlatools/Composer/ExtensionInstaller.php +++ b/src/Joomlatools/Composer/ExtensionInstaller.php @@ -33,6 +33,10 @@ public function __construct(IOInterface $io) public function execute() { + if (!Util::isJoomla() && !Util::isJoomlatoolsPlatform()) { + return true; + } + $application = Bootstrapper::getInstance()->getApplication(); if ($application === false) diff --git a/src/Joomlatools/Composer/Plugin.php b/src/Joomlatools/Composer/Plugin.php index f20b405..4bf6fae 100644 --- a/src/Joomlatools/Composer/Plugin.php +++ b/src/Joomlatools/Composer/Plugin.php @@ -40,13 +40,13 @@ class Plugin implements PluginInterface, EventSubscriberInterface */ public function activate(Composer $composer, IOInterface $io) { - if (!Util::isJoomla() && !Util::isJoomlatoolsPlatform()) { - throw new \RuntimeException('Working directory is not a valid Joomla installation'); - } - $this->_composer = $composer; $this->_io = $io; + if (!Util::isJoomla() && !Util::isJoomlatoolsPlatform()) { + return true; + } + $credentials = $this->_composer->getConfig()->get('joomla'); if(is_null($credentials) || !is_array($credentials)) { @@ -64,7 +64,7 @@ public function activate(Composer $composer, IOInterface $io) public static function getSubscribedEvents() { return array( - ScriptEvents::POST_AUTOLOAD_DUMP => 'postAutoloadDump' + 'post-autoload-dump' => 'postAutoloadDump' ); } @@ -73,4 +73,14 @@ public function postAutoloadDump(Event $event) $extensionInstaller = new ExtensionInstaller($this->_io); $extensionInstaller->execute(); } + + public function uninstall(Composer $composer, IOInterface $io) + { + // TODO: Implement uninstall() method. + } + + public function deactivate(Composer $composer, IOInterface $io) + { + // TODO: Implement deactivate() method. + } } \ No newline at end of file