Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| UserRequirementsConditionCheckerFactory | |
100.00% |
16 / 16 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUserRequirementsConditionChecker | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\User; |
| 8 | |
| 9 | use MediaWiki\Config\ServiceOptions; |
| 10 | use MediaWiki\Context\IContextSource; |
| 11 | use MediaWiki\HookContainer\HookContainer; |
| 12 | use MediaWiki\Permissions\GroupPermissionsLookup; |
| 13 | use MediaWiki\User\Registration\UserRegistrationLookup; |
| 14 | use Psr\Log\LoggerInterface; |
| 15 | |
| 16 | /** |
| 17 | * @since 1.45 |
| 18 | */ |
| 19 | class UserRequirementsConditionCheckerFactory { |
| 20 | |
| 21 | /** @var UserRequirementsConditionChecker[] */ |
| 22 | private $instances = []; |
| 23 | |
| 24 | public function __construct( |
| 25 | private readonly ServiceOptions $options, |
| 26 | private readonly GroupPermissionsLookup $groupPermissionsLookup, |
| 27 | private readonly HookContainer $hookContainer, |
| 28 | private readonly LoggerInterface $logger, |
| 29 | private readonly UserEditTracker $userEditTracker, |
| 30 | private readonly UserRegistrationLookup $userRegistrationLookup, |
| 31 | private readonly UserFactory $userFactory, |
| 32 | private readonly IContextSource $context, |
| 33 | ) { |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @param UserGroupManager $userGroupManager |
| 38 | * @param string|false $wikiId |
| 39 | * @return UserRequirementsConditionChecker |
| 40 | */ |
| 41 | public function getUserRequirementsConditionChecker( |
| 42 | UserGroupManager $userGroupManager, |
| 43 | $wikiId = UserIdentity::LOCAL |
| 44 | ): UserRequirementsConditionChecker { |
| 45 | $key = (string)$wikiId; |
| 46 | if ( !isset( $this->instances[$key] ) ) { |
| 47 | $this->instances[$key] = new UserRequirementsConditionChecker( |
| 48 | $this->options, |
| 49 | $this->groupPermissionsLookup, |
| 50 | $this->hookContainer, |
| 51 | $this->logger, |
| 52 | $this->userEditTracker, |
| 53 | $this->userRegistrationLookup, |
| 54 | $this->userFactory, |
| 55 | $this->context, |
| 56 | $userGroupManager, |
| 57 | $wikiId, |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | return $this->instances[$key]; |
| 62 | } |
| 63 | } |