MediaWiki  master
ComposerPackageModifier.php
Go to the documentation of this file.
1 <?php
2 
3 use Composer\Package\Link;
4 use Composer\Package\Package;
5 use Composer\Semver\Constraint\Constraint;
6 
12 
13  private const MEDIAWIKI_PACKAGE_NAME = 'mediawiki/mediawiki';
14 
15  protected $package;
16  protected $versionNormalizer;
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( [ $link ] );
53  }
54 
55 }
ComposerPackageModifier\setProvidesMediaWiki
setProvidesMediaWiki()
Definition: ComposerPackageModifier.php:34
ComposerPackageModifier\$versionFetcher
$versionFetcher
Definition: ComposerPackageModifier.php:17
ComposerPackageModifier
Definition: ComposerPackageModifier.php:11
ComposerPackageModifier\$package
$package
Definition: ComposerPackageModifier.php:15
ComposerPackageModifier\MEDIAWIKI_PACKAGE_NAME
const MEDIAWIKI_PACKAGE_NAME
Definition: ComposerPackageModifier.php:13
ComposerPackageModifier\__construct
__construct(Package $package, ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher)
Definition: ComposerPackageModifier.php:24
MediaWikiVersionFetcher
Provides access to MediaWiki's version without requiring MediaWiki (or anything else) being loaded fi...
Definition: MediaWikiVersionFetcher.php:9
ComposerPackageModifier\$versionNormalizer
$versionNormalizer
Definition: ComposerPackageModifier.php:16
ComposerVersionNormalizer
Definition: ComposerVersionNormalizer.php:7