Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PageStoreFactory
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 getPageStore
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace MediaWiki\Page;
4
5use MediaWiki\Cache\LinkCache;
6use MediaWiki\Config\ServiceOptions;
7use MediaWiki\DAO\WikiAwareEntity;
8use MediaWiki\Title\NamespaceInfo;
9use MediaWiki\Title\TitleParser;
10use Wikimedia\Rdbms\ILBFactory;
11use Wikimedia\Stats\StatsFactory;
12
13/**
14 * @since 1.36
15 */
16class PageStoreFactory {
17
18    /**
19     * @internal For use by service wiring
20     */
21    public const CONSTRUCTOR_OPTIONS = PageStore::CONSTRUCTOR_OPTIONS;
22
23    private ServiceOptions $options;
24    private ILBFactory $dbLoadBalancerFactory;
25    private NamespaceInfo $namespaceInfo;
26    private TitleParser $titleParser;
27    private LinkCache $linkCache;
28    private StatsFactory $stats;
29
30    public function __construct(
31        ServiceOptions $options,
32        ILBFactory $dbLoadBalancerFactory,
33        NamespaceInfo $namespaceInfo,
34        TitleParser $titleParser,
35        LinkCache $linkCache,
36        StatsFactory $stats
37    ) {
38        $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
39
40        $this->options = $options;
41        $this->dbLoadBalancerFactory = $dbLoadBalancerFactory;
42        $this->namespaceInfo = $namespaceInfo;
43        $this->titleParser = $titleParser;
44        $this->linkCache = $linkCache;
45        $this->stats = $stats;
46    }
47
48    /**
49     * @param string|false $wikiId
50     *
51     * @return PageStore
52     */
53    public function getPageStore( $wikiId = WikiAwareEntity::LOCAL ): PageStore {
54        return new PageStore(
55            $this->options,
56            $this->dbLoadBalancerFactory->getMainLB( $wikiId ),
57            $this->namespaceInfo,
58            $this->titleParser,
59            $wikiId !== WikiAwareEntity::LOCAL ? null : $this->linkCache,
60            $this->stats,
61            $wikiId
62        );
63    }
64
65}