MediaWiki master
CrossWikiBlockTargetFactory.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Block;
4
10
18 private ActorStoreFactory $actorStoreFactory;
19 private UserNameUtils $userNameUtils;
20 private ServiceOptions $options;
21
23 private array $storeCache = [];
24
29
30 public function __construct(
31 ServiceOptions $options,
32 ActorStoreFactory $actorStoreFactory,
33 UserNameUtils $userNameUtils
34 ) {
35 $this->options = $options;
36 $this->actorStoreFactory = $actorStoreFactory;
37 $this->userNameUtils = $userNameUtils;
38 }
39
40 public function getFactory( string|false $wikiId = WikiAwareEntity::LOCAL ): BlockTargetFactory {
41 if ( is_string( $wikiId ) && WikiMap::getCurrentWikiId() === $wikiId ) {
42 $wikiId = WikiAwareEntity::LOCAL;
43 }
44
45 $storeCacheKey = $wikiId === WikiAwareEntity::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
46 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
47 $this->storeCache[$storeCacheKey] = new BlockTargetFactory(
48 $this->options,
49 $this->actorStoreFactory->getUserIdentityLookup( $wikiId ),
50 $this->userNameUtils,
51 $wikiId
52 );
53 }
54 return $this->storeCache[$storeCacheKey];
55 }
56}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
Factory for BlockTarget objects.
getFactory(string|false $wikiId=WikiAwareEntity::LOCAL)
__construct(ServiceOptions $options, ActorStoreFactory $actorStoreFactory, UserNameUtils $userNameUtils)
A class for passing options to services.
ActorStore factory for any wiki domain.
UserNameUtils service.
Tools for dealing with other locally-hosted wikis.
Definition WikiMap.php:19
Marker interface for entities aware of the wiki they belong to.