MediaWiki master
BlockUtilsFactory.php
Go to the documentation of this file.
1<?php
2
22namespace MediaWiki\Block;
23
28
37
38 private ServiceOptions $options;
39 private ActorStoreFactory $actorStoreFactory;
40 private UserNameUtils $userNameUtils;
41 private LBFactory $loadBalancerFactory;
42
44 private array $storeCache = [];
45
46 public function __construct(
47 ServiceOptions $options,
48 ActorStoreFactory $actorStoreFactory,
49 UserNameUtils $userNameUtils,
50 LBFactory $loadBalancerFactory
51 ) {
52 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
53
54 $this->options = $options;
55 $this->actorStoreFactory = $actorStoreFactory;
56 $this->userNameUtils = $userNameUtils;
57 $this->loadBalancerFactory = $loadBalancerFactory;
58 }
59
64 public function getBlockUtils( $wikiId = Block::LOCAL ): BlockUtils {
65 if ( is_string( $wikiId ) && $this->loadBalancerFactory->getLocalDomainID() === $wikiId ) {
66 $wikiId = Block::LOCAL;
67 }
68
69 $storeCacheKey = $wikiId === Block::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
70 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
71 $this->storeCache[$storeCacheKey] = new BlockUtils(
72 $this->options,
73 $this->actorStoreFactory->getUserIdentityLookup( $wikiId ),
74 $this->userNameUtils,
75 $wikiId
76 );
77 }
78 return $this->storeCache[$storeCacheKey];
79 }
80}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
__construct(ServiceOptions $options, ActorStoreFactory $actorStoreFactory, UserNameUtils $userNameUtils, LBFactory $loadBalancerFactory)
Backend class for blocking utils.
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
UserNameUtils service.