Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
BlockUtilsFactory
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getBlockUtils
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 *
19 * @file
20 */
21
22namespace MediaWiki\Block;
23
24use MediaWiki\WikiMap\WikiMap;
25
26/**
27 * @deprecated since 1.44 use CrossWikiBlockTargetFactory
28 * @since 1.42
29 */
30class BlockUtilsFactory {
31    private CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory;
32
33    /** @var BlockUtils[] */
34    private array $storeCache = [];
35
36    public function __construct(
37        CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory
38    ) {
39        $this->crossWikiBlockTargetFactory = $crossWikiBlockTargetFactory;
40    }
41
42    /**
43     * @param string|false $wikiId
44     * @return BlockUtils
45     */
46    public function getBlockUtils( $wikiId = Block::LOCAL ): BlockUtils {
47        if ( is_string( $wikiId ) && WikiMap::getCurrentWikiId() === $wikiId ) {
48            $wikiId = Block::LOCAL;
49        }
50
51        $storeCacheKey = $wikiId === Block::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
52        if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
53            $this->storeCache[$storeCacheKey] = new BlockUtils(
54                $this->crossWikiBlockTargetFactory->getFactory( $wikiId )
55            );
56        }
57        return $this->storeCache[$storeCacheKey];
58    }
59}