summaryrefslogtreecommitdiff
path: root/includes/composer/ComposerHookHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/composer/ComposerHookHandler.php')
-rw-r--r--includes/composer/ComposerHookHandler.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/includes/composer/ComposerHookHandler.php b/includes/composer/ComposerHookHandler.php
new file mode 100644
index 00000000..2587b1d8
--- /dev/null
+++ b/includes/composer/ComposerHookHandler.php
@@ -0,0 +1,37 @@
+<?php
+
+use Composer\Package\Package;
+use Composer\Script\Event;
+
+$GLOBALS['IP'] = __DIR__ . '/../../';
+require_once __DIR__ . '/../AutoLoader.php';
+
+/**
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+class ComposerHookHandler {
+
+ public static function onPreUpdate( Event $event ) {
+ self::handleChangeEvent( $event );
+ }
+
+ public static function onPreInstall( Event $event ) {
+ self::handleChangeEvent( $event );
+ }
+
+ private static function handleChangeEvent( Event $event ) {
+ $package = $event->getComposer()->getPackage();
+
+ if ( $package instanceof Package ) {
+ $packageModifier = new ComposerPackageModifier(
+ $package,
+ new ComposerVersionNormalizer(),
+ new MediaWikiVersionFetcher()
+ );
+
+ $packageModifier->setProvidesMediaWiki();
+ }
+ }
+
+}