wfMsgForContentNoTrans() was removed
[mediawiki.git] / includes / composer / ComposerPackageModifier.php
blob64c69ef52939fab852f57a6fa06f31499f1023b2
1 <?php
3 use Composer\Package\Link;
4 use Composer\Package\LinkConstraint\VersionConstraint;
5 use Composer\Package\Package;
7 /**
8 * @licence GNU GPL v2+
9 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
11 class ComposerPackageModifier {
13 const MEDIAWIKI_PACKAGE_NAME = 'mediawiki/mediawiki';
15 protected $package;
16 protected $versionNormalizer;
17 protected $versionFetcher;
19 public function __construct( Package $package,
20 ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher
21 ) {
22 $this->package = $package;
23 $this->versionNormalizer = $versionNormalizer;
24 $this->versionFetcher = $versionFetcher;
27 public function setProvidesMediaWiki() {
28 $this->setLinkAsProvides( $this->newMediaWikiLink() );
31 private function setLinkAsProvides( Link $link ) {
32 $this->package->setProvides( array( $link ) );
35 private function newMediaWikiLink() {
36 $version = $this->getMediaWikiVersionConstraint();
38 $link = new Link(
39 '__root__',
40 self::MEDIAWIKI_PACKAGE_NAME,
41 $version,
42 'provides',
43 $version->getPrettyString()
46 return $link;
49 private function getMediaWikiVersionConstraint() {
50 $mvVersion = $this->versionFetcher->fetchVersion();
51 $mvVersion = $this->versionNormalizer->normalizeSuffix( $mvVersion );
53 $version = new VersionConstraint(
54 '==',
55 $this->versionNormalizer->normalizeLevelCount( $mvVersion )
57 $version->setPrettyString( $mvVersion );
59 return $version;