MediaWiki master
UserGroupManagerFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\User;
22
28use Psr\Log\LoggerInterface;
31
39 private ServiceOptions $options;
40 private ReadOnlyMode $readOnlyMode;
41 private ILBFactory $dbLoadBalancerFactory;
42 private UserEditTracker $userEditTracker;
43 private GroupPermissionsLookup $groupPermissionLookup;
44 private JobQueueGroupFactory $jobQueueGroupFactory;
45 private LoggerInterface $logger;
46
48 private $clearCacheCallbacks;
49
50 private HookContainer $hookContainer;
51 private TempUserConfig $tempUserConfig;
52
56 private $instances = [];
57
70 public function __construct(
71 ServiceOptions $options,
72 ReadOnlyMode $readOnlyMode,
73 ILBFactory $dbLoadBalancerFactory,
74 HookContainer $hookContainer,
75 UserEditTracker $userEditTracker,
76 GroupPermissionsLookup $groupPermissionsLookup,
77 JobQueueGroupFactory $jobQueueGroupFactory,
78 LoggerInterface $logger,
79 TempUserConfig $tempUserConfig,
80 array $clearCacheCallbacks = []
81 ) {
82 $this->options = $options;
83 $this->readOnlyMode = $readOnlyMode;
84 $this->dbLoadBalancerFactory = $dbLoadBalancerFactory;
85 $this->hookContainer = $hookContainer;
86 $this->userEditTracker = $userEditTracker;
87 $this->groupPermissionLookup = $groupPermissionsLookup;
88 $this->jobQueueGroupFactory = $jobQueueGroupFactory;
89 $this->logger = $logger;
90 $this->tempUserConfig = $tempUserConfig;
91 $this->clearCacheCallbacks = $clearCacheCallbacks;
92 }
93
98 public function getUserGroupManager( $wikiId = UserIdentity::LOCAL ): UserGroupManager {
99 if ( is_string( $wikiId ) && $this->dbLoadBalancerFactory->getLocalDomainID() === $wikiId ) {
100 $wikiId = UserIdentity::LOCAL;
101 }
102 $key = (string)$wikiId;
103 if ( !isset( $this->instances[$key] ) ) {
104 $this->instances[$key] = new UserGroupManager(
105 $this->options,
106 $this->readOnlyMode,
107 $this->dbLoadBalancerFactory,
108 $this->hookContainer,
109 $this->userEditTracker,
110 $this->groupPermissionLookup,
111 $this->jobQueueGroupFactory->makeJobQueueGroup( $wikiId ),
112 $this->logger,
113 $this->tempUserConfig,
114 $this->clearCacheCallbacks,
115 $wikiId
116 );
117 }
118 return $this->instances[$key];
119 }
120}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
A class for passing options to services.
Class to construct JobQueueGroups.
Track info about user edit counts and timings.
Factory service for UserGroupManager instances.
getUserGroupManager( $wikiId=UserIdentity::LOCAL)
__construct(ServiceOptions $options, ReadOnlyMode $readOnlyMode, ILBFactory $dbLoadBalancerFactory, HookContainer $hookContainer, UserEditTracker $userEditTracker, GroupPermissionsLookup $groupPermissionsLookup, JobQueueGroupFactory $jobQueueGroupFactory, LoggerInterface $logger, TempUserConfig $tempUserConfig, array $clearCacheCallbacks=[])
Determine whether a site is currently in read-only mode.
Interface for temporary user creation config and name matching.
Manager of ILoadBalancer objects and, indirectly, IDatabase connections.
Utility class for bot passwords.