summaryrefslogtreecommitdiff
path: root/includes/composer/ComposerPackageModifier.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/composer/ComposerPackageModifier.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/composer/ComposerPackageModifier.php')
-rw-r--r--includes/composer/ComposerPackageModifier.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/includes/composer/ComposerPackageModifier.php b/includes/composer/ComposerPackageModifier.php
new file mode 100644
index 00000000..64c69ef5
--- /dev/null
+++ b/includes/composer/ComposerPackageModifier.php
@@ -0,0 +1,62 @@
+<?php
+
+use Composer\Package\Link;
+use Composer\Package\LinkConstraint\VersionConstraint;
+use Composer\Package\Package;
+
+/**
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+class ComposerPackageModifier {
+
+ const MEDIAWIKI_PACKAGE_NAME = 'mediawiki/mediawiki';
+
+ protected $package;
+ protected $versionNormalizer;
+ protected $versionFetcher;
+
+ public function __construct( Package $package,
+ ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher
+ ) {
+ $this->package = $package;
+ $this->versionNormalizer = $versionNormalizer;
+ $this->versionFetcher = $versionFetcher;
+ }
+
+ public function setProvidesMediaWiki() {
+ $this->setLinkAsProvides( $this->newMediaWikiLink() );
+ }
+
+ private function setLinkAsProvides( Link $link ) {
+ $this->package->setProvides( array( $link ) );
+ }
+
+ private function newMediaWikiLink() {
+ $version = $this->getMediaWikiVersionConstraint();
+
+ $link = new Link(
+ '__root__',
+ self::MEDIAWIKI_PACKAGE_NAME,
+ $version,
+ 'provides',
+ $version->getPrettyString()
+ );
+
+ return $link;
+ }
+
+ private function getMediaWikiVersionConstraint() {
+ $mvVersion = $this->versionFetcher->fetchVersion();
+ $mvVersion = $this->versionNormalizer->normalizeSuffix( $mvVersion );
+
+ $version = new VersionConstraint(
+ '==',
+ $this->versionNormalizer->normalizeLevelCount( $mvVersion )
+ );
+ $version->setPrettyString( $mvVersion );
+
+ return $version;
+ }
+
+}