-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable incompatible pw-module installer with event listener in plugin
- Loading branch information
1 parent
15967c1
commit c63afc7
Showing
4 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,11 @@ | |
namespace wireframe\ComposerInstaller; | ||
|
||
use Composer\Composer; | ||
use Composer\EventDispatcher\EventSubscriberInterface; | ||
use Composer\IO\IOInterface; | ||
use Composer\Plugin\PluginInterface; | ||
use Composer\Installer\PackageEvent; | ||
use Composer\Installer\PackageEvents; | ||
|
||
/** | ||
* The Plugin class | ||
|
@@ -14,7 +17,7 @@ | |
* @author Teppo Koivula <[email protected]> | ||
* @license Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/ | ||
*/ | ||
class Plugin implements PluginInterface | ||
class Plugin implements PluginInterface, EventSubscriberInterface | ||
{ | ||
/** | ||
* Register custom installers for ProcessWire modules and site profiles. | ||
|
@@ -28,4 +31,38 @@ public function activate(Composer $composer, IOInterface $io) | |
$installationManager->addInstaller(new ModuleInstaller($io, $composer)); | ||
$installationManager->addInstaller(new SiteProfileInstaller($io, $composer)); | ||
} | ||
|
||
/** | ||
* Register pre package install event listener | ||
* | ||
* @return array | ||
*/ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
PackageEvents::PRE_PACKAGE_INSTALL => [ | ||
array('prePackageInstall', 0) | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Pre package install event listener | ||
* | ||
* wireframe-framework/processwire-composer-installer and hari/pw-module are not fully compatible, | ||
* which means that when wireframe-framework/processwire-composer-installer is enabled, we need to | ||
* disable the hari/pw-module SystemInstaller composer-installer. | ||
* | ||
* @param PackageEvent $event | ||
*/ | ||
public static function prePackageInstall(PackageEvent $event) | ||
{ | ||
$package = $event->getOperation()->getPackage(); | ||
if ($package->getType() !== 'pw-module') return; | ||
$installationManager = $event->getComposer()->getInstallationManager(); | ||
$moduleInstaller = $installationManager->getInstaller('pw-module'); | ||
if (strpos(get_class($moduleInstaller), 'PW\Composer\SystemInstaller') === 0) { | ||
$installationManager->removeInstaller($moduleInstaller); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.