blob: 731715fdcc9e845e95a0a41586e7226ebb64773e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
/**
* @file
* @author Niklas Laxström
* @license GPL-2.0-or-later
*/
namespace MediaWiki\Extensions\Translate;
use MediaWiki\Extensions\Translate\Statistics\TranslatorActivity;
use MediaWiki\Extensions\Translate\Synchronization\GroupSynchronizationCache;
use MediaWiki\Extensions\Translate\Utilities\ParsingPlaceholderFactory;
use MediaWiki\MediaWikiServices;
use Psr\Container\ContainerInterface;
/**
* Minimal service container.
*
* Main purpose is to give type-hinted getters for services defined in this extensions.
*
* @since 2020.04
*/
class Services implements ContainerInterface {
/** @var self */
private static $instance;
/** @var MediaWikiServices */
private $container;
private function __construct( MediaWikiServices $container ) {
$this->container = $container;
}
public static function getInstance(): Services {
self::$instance = self::$instance ?? new self( MediaWikiServices::getInstance() );
return self::$instance;
}
/** @inheritDoc */
public function get( $id ) {
// Can be changed to using ::get once we drop support for MW 1.33
return $this->container->getService( $id );
}
/** @inheritDoc */
public function has( $id ) {
// Can be changed to using ::has once we drop support for MW 1.33
return $this->container->hasService( $id );
}
public function getGroupSynchronizationCache(): GroupSynchronizationCache {
return $this->container->getService( 'Translate:GroupSynchronizationCache' );
}
/** @since 2020.07 */
public function getParsingPlaceholderFactory(): ParsingPlaceholderFactory {
return $this->container->getService( 'Translate:ParsingPlaceholderFactory' );
}
public function getTranslatorActivity(): TranslatorActivity {
return $this->container->getService( 'Translate:TranslatorActivity' );
}
}
|