MediaWiki master
BlockUtilsFactory.php
Go to the documentation of this file.
1<?php
2
8namespace MediaWiki\Block;
9
11
17 private CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory;
18
20 private array $storeCache = [];
21
22 public function __construct(
23 CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory
24 ) {
25 $this->crossWikiBlockTargetFactory = $crossWikiBlockTargetFactory;
26 }
27
28 public function getBlockUtils( string|false $wikiId = Block::LOCAL ): BlockUtils {
29 if ( is_string( $wikiId ) && WikiMap::getCurrentWikiId() === $wikiId ) {
30 $wikiId = Block::LOCAL;
31 }
32
33 $storeCacheKey = $wikiId === Block::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
34 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
35 $this->storeCache[$storeCacheKey] = new BlockUtils(
36 $this->crossWikiBlockTargetFactory->getFactory( $wikiId )
37 );
38 }
39 return $this->storeCache[$storeCacheKey];
40 }
41}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
__construct(CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory)
getBlockUtils(string|false $wikiId=Block::LOCAL)
Backend class for blocking utils.
Tools for dealing with other locally-hosted wikis.
Definition WikiMap.php:19
const LOCAL
Wiki ID value to use with instances that are defined relative to the local wiki.