3 namespace MediaWiki\FileBackend\LockManager
;
8 * Service to construct LockManagerGroups.
10 class LockManagerGroupFactory
{
12 private $defaultDomain;
15 private $lockManagerConfigs;
17 /** @var LockManagerGroup[] (domain => LockManagerGroup) */
18 private $instances = [];
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;
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];