Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / filebackend / lockmanager / LockManagerGroupFactory.php
blob088e149084d5f41ecc533669415c8a61a1c5316e
1 <?php
3 namespace MediaWiki\FileBackend\LockManager;
5 use LockManagerGroup;
7 /**
8 * Service to construct LockManagerGroups.
9 */
10 class LockManagerGroupFactory {
11 /** @var string */
12 private $defaultDomain;
14 /** @var array */
15 private $lockManagerConfigs;
17 /** @var LockManagerGroup[] (domain => LockManagerGroup) */
18 private $instances = [];
20 /**
21 * Do not call directly, use MediaWikiServices.
23 * @param string $defaultDomain
24 * @param array $lockManagerConfigs In format of $wgLockManagers
26 public function __construct( $defaultDomain, array $lockManagerConfigs ) {
27 $this->defaultDomain = $defaultDomain;
28 $this->lockManagerConfigs = $lockManagerConfigs;
31 /**
32 * @param string|null|false $domain Domain (usually wiki ID). false for the default (normally
33 * the current wiki's domain).
34 * @return LockManagerGroup
36 public function getLockManagerGroup( $domain = false ): LockManagerGroup {
37 if ( $domain === false || $domain === null ) {
38 $domain = $this->defaultDomain;
41 if ( !isset( $this->instances[$domain] ) ) {
42 $this->instances[$domain] =
43 new LockManagerGroup( $domain, $this->lockManagerConfigs );
46 return $this->instances[$domain];