MediaWiki REL1_40
ComposerPackageModifier.php
Go to the documentation of this file.
1<?php
2
3use Composer\Package\Link;
4use Composer\Package\Package;
5use Composer\Semver\Constraint\Constraint;
6
12
13 private const MEDIAWIKI_PACKAGE_NAME = 'mediawiki/mediawiki';
14
15 protected $package;
17 protected $versionFetcher;
18
24 public function __construct(
25 Package $package,
28 ) {
29 $this->package = $package;
30 $this->versionNormalizer = $versionNormalizer;
31 $this->versionFetcher = $versionFetcher;
32 }
33
34 public function setProvidesMediaWiki() {
35 $mvVersion = $this->versionFetcher->fetchVersion();
36 $mvVersion = $this->versionNormalizer->normalizeSuffix( $mvVersion );
37
38 $version = new Constraint(
39 '==',
40 $this->versionNormalizer->normalizeLevelCount( $mvVersion )
41 );
42 $version->setPrettyString( $mvVersion );
43
44 $link = new Link(
45 '__root__',
46 self::MEDIAWIKI_PACKAGE_NAME,
47 $version,
48 'provides',
49 $version->getPrettyString()
50 );
51
52 $this->package->setProvides( [ self::MEDIAWIKI_PACKAGE_NAME => $link ] );
53 }
54
55}
__construct(Package $package, ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher)
Provides access to MediaWiki's version without requiring MediaWiki (or anything else) being loaded fi...